//
//  ShopCartViewController.m
//  ShoppingExperience
//
//  Created by LiYinDi on 15-1-4.
//  Copyright (c) 2015年 RuiBen. All rights reserved.
//

#import "ShopCartViewController.h"
#import "ShopCartTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "GuideListTableViewCell.h"
#import "OldMeterialTableViewCell.h"

#import "HZAreaPickerView.h"
#import <CoreLocation/CoreLocation.h>
#import "SearchMemberTableViewCell.h"
#import "FPNumberPadView.h"
#import "OrderViewController.h"

////#import "CBSDK.h"
#import <CommonCrypto/CommonDigest.h>
//#import "ASIFormDataRequest.h"
#import "SelectDepositViewController.h"
#import "CommonDetailTableViewCell.h"
#import "AddNewDepositViewController.h"
#import "CashierViewController.h"
#import "AddMemberViewController.h"

@interface ShopCartViewController ()<ShopCartTableViewCellDelegate,HZAreaPickerDelegate,FPNumberPadViewDelegate,SelectDepositDelegate,AddNewDepositDelegate,CashierViewControllerDelegate,OldMeterialCellDelegate,AddMemberDelegate>
{
     AddMemberViewController *addMemberVC;
    SelectDepositViewController *selectDepositVC;
    CashierViewController *cashierVC;
//    AddNewDepositViewController *addNewDepositVC;
    NSUInteger _productPageIndex;
    NSUInteger _productTotalCount;
    NSUInteger _productTotalPage;
    
    NSUInteger _memberPageIndex;
    NSUInteger _memberTotalCount;
    NSUInteger _memberTotalPage;
    
    NSMutableArray *memberCodeArray;
    NSMutableArray *memberNameArray;
    NSMutableArray *memberPhoneArray;
    NSMutableArray *memberGradeArray;
    NSMutableArray *memberAddressArray;
    NSMutableArray *memberIntegralArray;
    NSMutableArray *memberIntegralAmountArray;
    NSMutableArray *memberSexArray;

    
    NSMutableArray *shopCartAllArray;
    NSMutableArray *shopCartListArray;
    NSMutableArray *shopCartDocTypeArray;
    NSMutableArray *shopCartNameArray;
    NSMutableArray *shopCartImageArray;
    NSMutableArray *shopCartSaleArray;
    NSMutableArray *shopCartMarketArray;
    NSMutableArray *shopCartCodeArray;
    NSMutableArray *shopCartAttributeArray;
    
    NSMutableArray *shopCartAddressArray;
    NSMutableArray *shopCartWeightArray;
   
   // NSInteger totalResultValue;
    
    NSMutableArray *selectedCodeArray;
    NSMutableArray *selectedCountArray;
    
    NSString *weightStr;
    NSString *cutGoldStr;
    NSString *processPriceStr;
    NSString *todayGoldPriceStr;
    
    NSInteger priceDetailCellTag;
    BOOL isOpened;
    BOOL chengSeListIsOpen;
    
    NSMutableArray *mGuidesArray;
    NSMutableArray *guideNameArray;
    NSMutableArray *guideCodeArray;
    NSString *guideCodeStr;
    NSString *memberCodeStr;
    
    NSMutableArray *chengSeCodeArray;
    NSMutableArray *chengSeNameArray;
    
    
    NSMutableArray *oldChengSeArray;
    NSMutableArray *oldChengSeCodeArray;
    NSMutableArray *oldWeightArray;
    NSMutableArray *oldRecyclePriceArray;
     NSMutableArray *oldRealPriceArray;
    NSMutableArray *oldLossArray;
    NSMutableArray *oldPriceArray;
    
    NSMutableArray *featureCodeArray;
    NSMutableArray *featureNameArray;
    NSMutableArray *selectFeatureCodeArray;
    NSString *sexStr;
    
    NSString *provinceStr;
    NSString *cityStr;
    NSString *regionStr;
    NSString *addressStr;
    NSString *qrCodeStr;
//    NSTimer * timer;
    NSString *openIdStr;
    
    NSString *selectDepositCellTagStr;
    
    float cashierAmountFloat;
    float balanceAmountFloat;
    float oldMeterialTotalAmountFloat;
    float priceDetail1DiscountValueFloat;
    float priceDetailDiscountValueFloat;
    
    
     UITextField *inputTextField;
    
     //BOOL isLoad;
    
    BOOL memberGradeIsOpen;
    NSMutableArray *memberGradeNameArray;
    NSMutableArray *memberGradeCodeArray;
    NSString *memberGradeCodeStr;
    NSString *integralAvailabalStr;
    
    NSString *entryString;

}
@property (strong, nonatomic) NSString *areaValue, *cityValue;
@property (strong, nonatomic) HZAreaPickerView *locatePicker;

//@property (nonatomic, strong) NSMutableString *textViewText;
@property (nonatomic, copy) NSString *TPFToken;
@end

@implementation ShopCartViewController
@synthesize areaValue=_areaValue, cityValue=_cityValue;
@synthesize locatePicker=_locatePicker;
-(void)viewWillAppear:(BOOL)animated
{
  //  if ([[Global getIsHZ] isEqualToString:@"NOTHZ"]) {
if ([_isLoad isEqualToString:@"Y"]) {
    if (selectDepositVC.view!=nil) {
        
        [selectDepositVC removeFromParentViewController];
        [selectDepositVC.view removeFromSuperview];
        
    }
    if (addMemberVC.view!=nil) {
        if (addMemberVC.timer!=nil) {
            [addMemberVC.timer invalidate];
            addMemberVC.timer=nil;
        }
        
        [addMemberVC removeFromParentViewController];
        [addMemberVC.view removeFromSuperview];
        
    }

    if (cashierVC.view!=nil) {
        
        [cashierVC removeFromParentViewController];
        [cashierVC.view removeFromSuperview];
        
    }
  ///  NSLog(@"_productOrDetailStr====%@",_productOrDetailStr);
        if ([_productOrDetailStr isEqualToString:@"DETAIL"]||[_productOrDetailStr isEqualToString:@"PRODUCT"]) {
            _shopCartBackBtn.hidden=NO;
        }
        else
        {
            _shopCartBackBtn.hidden=YES;
        }
    if ([Global getScanID]==1) {
        _shopCartBackBtn.hidden=YES;
    }
        shopCartAllArray=[NSMutableArray array];
        shopCartListArray=[NSMutableArray array];
        shopCartNameArray=[NSMutableArray array];
        shopCartDocTypeArray=[NSMutableArray array];
        shopCartImageArray=[NSMutableArray array];
        shopCartSaleArray=[NSMutableArray array];
        shopCartMarketArray=[NSMutableArray array];
        shopCartAttributeArray=[NSMutableArray array];
        shopCartCodeArray=[NSMutableArray array];
        shopCartAddressArray=[NSMutableArray array];
        shopCartWeightArray=[NSMutableArray array];
        
        selectedCodeArray=[NSMutableArray array];
        selectedCountArray=[NSMutableArray array];
        
        mGuidesArray=[NSMutableArray array];
        guideNameArray=[NSMutableArray array];
        guideCodeArray=[NSMutableArray array];
        _clearAllBtn.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
        _clearAllBtn.layer.borderWidth= 1.0f;
        _clearAllBtn.layer.cornerRadius=3;
        [_clearAllBtn addTarget:self action:@selector(clearAllBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        
        [self initPriceDetail];
        [self initPriceDetail1];
        [self initCashierViewContainer];
        [self initOldMeterialViewContainer];
    
        [self initSearMemberView];
        _productPageIndex=0;
        [self loadProductNextPage:_productPageIndex];
  //  }
//        else
//        {
////            [self hzSuccess];
//            [Global setIsHZ:@"NOTHZ"];
//        }
//    
    
}
}
-(void)initSearMemberView
{
    memberCodeArray=[NSMutableArray array];
    memberNameArray=[NSMutableArray array];
    memberPhoneArray=[NSMutableArray array];
    memberGradeArray=[NSMutableArray array];
    memberAddressArray=[NSMutableArray array];
    memberIntegralArray=[NSMutableArray array];
    memberIntegralAmountArray=[NSMutableArray array];
    memberSexArray=[NSMutableArray array];
    openIdStr=@"";
    [_searchMemberAlphaView setBackgroundColor:[Global parseColor:WESTORE_TRANSCLUCENT]];
    [_searchMemberAlphaView addTarget:self action:@selector(searchMemberAlphaViewClick) forControlEvents:UIControlEventTouchUpInside];
    
    CGRect frame1=_searchMemberViewContainer.frame;
    frame1.origin.y=768;
    [_searchMemberViewContainer setFrame:frame1];
}
-(void)searchMemberAlphaViewClick
{
    [_searchMemberTextField resignFirstResponder];
    CGRect frame1=_searchMemberViewContainer.frame;
    frame1.origin.y=768;
    [_searchMemberViewContainer setFrame:frame1];
    
}
-(void) loadMemberNextPage:(NSUInteger)oldPageNum {
    if(oldPageNum!=0 && _memberTotalCount<=memberCodeArray.count)
        return;
    if(oldPageNum == 0){
        [memberCodeArray removeAllObjects];
        [_searchMemberTableView reloadData];
    }
    _memberPageIndex=oldPageNum+1;
    [self requestMemberList: _memberPageIndex pageSize:8];
}
-(void)requestMemberList:(NSUInteger)pageIndex pageSize:(NSUInteger)pageSize
{
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        NSNumber *pageSizeNumber = [NSNumber numberWithInteger:pageSize];
        NSNumber *pageIndexNumber = [NSNumber numberWithInteger:pageIndex];
        //        NSString *pageSizeStr=[NSString stringWithFormat:@"%d",pageSize];
        //        NSString *pageIndexStr=[NSString stringWithFormat:@"%d",pageIndex];
        
        [params setObject:pageSizeNumber forKey:@"PageSize"];
        [params setObject:pageIndexNumber forKey:@"PageIndex"];
        [params setObject:_searchMemberTextField.text forKey:@"KeyWord"];
        //   NSLog(@"paramsLIST====%@",params);
        [HttpRequest requestData:@"Guide/MemberList" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    //  NSLog(@"tttt11====%@",severDataDict.dataDict);
                    _memberTotalCount=[[severDataDict.dataDict objectForKey:@"TotalCount"] integerValue];
                    _totalMemberLabel.text=[NSString stringWithFormat:@"共有%lu个结果",(unsigned long)_memberTotalCount];
                    if (_memberTotalCount%8!=0) {
                        _memberTotalPage=_memberTotalCount/8+1;
                    }
                    else if (_memberTotalCount%8==0)
                    {
                        _memberTotalPage=_memberTotalCount/8;
                    }
                    NSMutableArray *mMembersArray=[NSMutableArray arrayWithArray:[severDataDict.dataDict objectForKey:@"DataLine"]];
                    // NSLog(@"mMembersArray===%@",mMembersArray);
                    if ( mMembersArray.count>0) {
                        for (int i=0; i< mMembersArray.count; i++) {
                            
                            [memberCodeArray addObject:[[mMembersArray objectAtIndex:i] objectForKey:@"UserCode"]];
                            [memberNameArray addObject:[[mMembersArray objectAtIndex:i] objectForKey:@"UserName"]];
                            [memberAddressArray addObject:[[mMembersArray objectAtIndex:i] objectForKey:@"Address"]];
                            [memberPhoneArray addObject:[[mMembersArray objectAtIndex:i] objectForKey:@"Phone"]];
                            [memberGradeArray addObject:[[mMembersArray objectAtIndex:i] objectForKey:@"Grade"]];
                            [memberIntegralArray addObject:[[mMembersArray objectAtIndex:i] objectForKey:@"Integral"]];
                            [memberIntegralAmountArray addObject:[[mMembersArray objectAtIndex:i] objectForKey:@"IntegralAmount"]];
                            [memberSexArray addObject:[[mMembersArray objectAtIndex:i] objectForKey:@"Sex"]];
                        }
                    }
                    
                    [_searchMemberTableView reloadData];
                    
                    
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    
//                    if (timer!=nil) {
//                        [timer invalidate];
//                        timer=nil;
//                    }
//
//                    UIViewController *controller=[[GlobalViewController alloc]init];
//                    [self.navigationController pushViewController:controller animated:YES];
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                        
                        if (_timer!=nil) {
                            [_timer invalidate];
                            _timer=nil;
                        }
                        [Global loginViewController:self noteStr:requestResultStr];
                      //  [Global loginViewController:self];
                    }

                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
        
    }
}

-(void)initPriceDetail1
{
    FPNumberPadView *numberPadView = [[FPNumberPadView alloc] initWithFrame:CGRectMake(0, 0, 948, 340)];
   // numberPadView.FPNumberPaddelegate=self;
    numberPadView.textField = _discountTextField1;
    
    FPNumberPadView *numberPadView1 = [[FPNumberPadView alloc] initWithFrame:CGRectMake(0, 0, 948, 340)];
    // numberPadView.FPNumberPaddelegate=self;
    numberPadView1.textField = _discountRateTextField;
    
   

    _discountTextField1.text=@"";
    _discountLabel1.text=@"";
    CGRect frame=_priceDetailViewContainer1.frame;
    frame.origin.y=768;
    [_priceDetailViewContainer1 setFrame:frame];
    //_remarkTextView1.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
    //_remarkTextView1.layer.borderWidth= 1.0f;
    //_remarkTextView1.layer.cornerRadius=3;
    
    [_priceDetailAlphaView1 setBackgroundColor:[Global parseColor:WESTORE_TRANSCLUCENT]];
    
    [_priceDetailAlphaView1 addTarget:self action:@selector(priceDetailAlphaView1Click) forControlEvents:UIControlEventTouchUpInside];
    [_discountTextField1 addTarget:self action:@selector(updateDiscountValueLabel:)  forControlEvents:UIControlEventEditingDidEnd];
    [_discountRateTextField addTarget:self action:@selector(updateDiscountValueLabel:)  forControlEvents:UIControlEventEditingDidEnd];

}
-(void)initPriceDetail
{
    FPNumberPadView *numberPadView = [[FPNumberPadView alloc] initWithFrame:CGRectMake(0, 0, 948, 340)];
    numberPadView.FPNumberPaddelegate=self;
    numberPadView.textField = _discountTextField;
    
    FPNumberPadView *numberPadView1 = [[FPNumberPadView alloc] initWithFrame:CGRectMake(0, 0, 948, 340)];
    numberPadView1.FPNumberPaddelegate=self;
    numberPadView1.textField = _cutGoldTextField;
    
    FPNumberPadView *numberPadView2 = [[FPNumberPadView alloc] initWithFrame:CGRectMake(0, 0, 948, 340)];
   // numberPadView2.FPNumberPaddelegate=self;
    numberPadView2.textField = _todayGoldPriceTextField;

    FPNumberPadView *numberPadView3 = [[FPNumberPadView alloc] initWithFrame:CGRectMake(0, 0, 948, 340)];
   // numberPadView3.FPNumberPaddelegate=self;
    numberPadView3.textField = _goldPriceTextField;

    FPNumberPadView *numberPadView4 = [[FPNumberPadView alloc] initWithFrame:CGRectMake(0, 0, 948, 340)];
  //  numberPadView4.FPNumberPaddelegate=self;
    numberPadView4.textField = _processPriceTextField;

    FPNumberPadView *numberPadView5 = [[FPNumberPadView alloc] initWithFrame:CGRectMake(0, 0, 948, 340)];
   // numberPadView5.FPNumberPaddelegate=self;
    numberPadView5.textField = _processFeeTextField;


    
    
    priceDetailCellTag=0;
    _weightLabel1.text=@"";
    _weightLabel2.text= @"";
    todayGoldPriceStr=@"";
    _todayGoldPriceTextField.text=@"";
    
    processPriceStr=@"";
    _processPriceTextField.text=@"";
    
    cutGoldStr=@"";
    _cutGoldTextField.text=@"";
    _discountTextField.text=@"";
    _goldPriceTextField.text=@"";
    _processFeeTextField.text=@"";
    _cutGoldLabel.text=@"";
    _discountLabel.text=@"";
    
    
//    _remarkTextView.text=@"";
//    _textviewImage.hidden=YES;
//    _textviewLabel.hidden=YES;
    _priceDetailtotalValueLabel.text=@"";
    priceDetailDiscountValueFloat=0;
    

    CGRect frame=_priceDetailViewContainer.frame;
    frame.origin.y=768;
    [_priceDetailViewContainer setFrame:frame];
    
    _todayGoldPriceTextField.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
    _todayGoldPriceTextField.layer.borderWidth= 1.0f;
    _todayGoldPriceTextField.layer.cornerRadius=3;
    
    _goldPriceTextField.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
    _goldPriceTextField.layer.borderWidth= 1.0f;
    _goldPriceTextField.layer.cornerRadius=3;
    
    _processPriceTextField.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
    _processPriceTextField.layer.borderWidth= 1.0f;
    _processPriceTextField.layer.cornerRadius=3;
    
    _processFeeTextField.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
    _processFeeTextField.layer.borderWidth= 1.0f;
    _processFeeTextField.layer.cornerRadius=3;
    
    
//    _remarkTextView.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
//    _remarkTextView.layer.borderWidth= 1.0f;
//    _remarkTextView.layer.cornerRadius=3;

    [_priceDetailAlphaView setBackgroundColor:[Global parseColor:WESTORE_TRANSCLUCENT]];
    
    [_priceDetailAlphaView addTarget:self action:@selector(priceDetailAlphaViewClick) forControlEvents:UIControlEventTouchUpInside];
    
    [_todayGoldPriceTextField addTarget:self action:@selector(updateColor:)  forControlEvents:UIControlEventEditingChanged];
    [_goldPriceTextField addTarget:self action:@selector(updateColor:)  forControlEvents:UIControlEventEditingChanged];
    [_processPriceTextField addTarget:self action:@selector(updateColor:)  forControlEvents:UIControlEventEditingChanged];
    [_processFeeTextField addTarget:self action:@selector(updateColor:)  forControlEvents:UIControlEventEditingChanged];
    [_cutGoldTextField addTarget:self action:@selector(updateColor:)  forControlEvents:UIControlEventEditingChanged];
    [_discountTextField addTarget:self action:@selector(updateColor:)  forControlEvents:UIControlEventEditingChanged];

    
     [_todayGoldPriceTextField addTarget:self action:@selector(updateCountLabel:)  forControlEvents:UIControlEventEditingDidEnd];
     [_goldPriceTextField addTarget:self action:@selector(updateCountLabel:)  forControlEvents:UIControlEventEditingDidEnd];
     [_processPriceTextField addTarget:self action:@selector(updateCountLabel:)  forControlEvents:UIControlEventEditingDidEnd];
     [_processFeeTextField addTarget:self action:@selector(updateCountLabel:)  forControlEvents:UIControlEventEditingDidEnd];
     [_cutGoldTextField addTarget:self action:@selector(updateCountLabel:)  forControlEvents:UIControlEventEditingDidEnd];
     [_discountTextField addTarget:self action:@selector(updateCountLabel:)  forControlEvents:UIControlEventEditingDidEnd];
}
-(void)initCashierViewContainer
{
   selectDepositCellTagStr=@"";
    entryString=@"";
     _cashierSearchMemberTextField.text=@"";
   
    
    FPNumberPadView *numberPadView2 = [[FPNumberPadView alloc] initWithFrame:CGRectMake(0, 0, 948, 340)];
    numberPadView2.FPNumberPaddelegate=self;
    numberPadView2.textField = _integralTextField;
    
    FPNumberPadView *numberPadView3 = [[FPNumberPadView alloc] initWithFrame:CGRectMake(0, 0, 948, 340)];
    numberPadView3.FPNumberPaddelegate=self;
    numberPadView3.textField = _deductibleTextField;
    
    //textField==_integralTextField||textField==_deductibleTextField
    
    _memberGradeLabel.hidden=YES;
    _memberGradeTagLabel.hidden=YES;
    _memberIntegralLabel.hidden=YES;
    _memberIntegralTagLabel.hidden=YES;
    CGRect frame=_cashierViewContainer.frame;
    frame.origin.y=768;
    [_cashierViewContainer setFrame:frame];
    memberCodeStr=@"";
    
     guideCodeStr=@"";
    
   isOpened=NO;
    CGRect rect1=_cashierConfirmBtn.frame;
    rect1.origin.y=_cashierLastView.frame.origin.y+ _cashierLastView.frame.size.height+10;
    _cashierConfirmBtn.frame=rect1;
    
    _cashierTextView.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
    _cashierTextView.layer.borderWidth= 1.0f;
    _cashierTextView.layer.cornerRadius=3;
    
    
    [_cashierSrollView setContentOffset:CGPointMake(0, 0)];
     [_cashierAlphaView setBackgroundColor:[Global parseColor:WESTORE_TRANSCLUCENT]];
    [_cashierAlphaView addTarget:self action:@selector(cashierAlphaViewClick1) forControlEvents:UIControlEventTouchUpInside];
    

    
    _cashierScanBtn.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
    _cashierScanBtn.layer.borderWidth= 1.0f;
    _cashierScanBtn.layer.cornerRadius=3;
    
    _selectDepositButton.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
    _selectDepositButton.layer.borderWidth= 1.0f;
    _selectDepositButton.layer.cornerRadius=3;

    _cashierDetailBtn.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
    _cashierDetailBtn.layer.borderWidth= 1.0f;
    _cashierDetailBtn.layer.cornerRadius=3;
    [_cashierDetailBtn addTarget:self action:@selector(cashierDetailBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [_addMemberButton addTarget:self action:@selector(addMemberBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    [_guideListBtn addTarget:self action:@selector(selectGuideBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    [_integralTextField addTarget:self action:@selector(updateValueLabel:)  forControlEvents:UIControlEventEditingChanged];
    [_deductibleTextField addTarget:self action:@selector(updateValueLabel:)  forControlEvents:UIControlEventEditingChanged];
    [_oldMeterialTextField addTarget:self action:@selector(updateValueLabel:)  forControlEvents:UIControlEventEditingChanged];
   
}
-(void)initOldMeterialViewContainer
{
    FPNumberPadView *numberPadView2 = [[FPNumberPadView alloc] initWithFrame:CGRectMake(0, 0, 948, 340)];
    numberPadView2.textField = _weightTextField;
    
    FPNumberPadView *numberPadView3 = [[FPNumberPadView alloc] initWithFrame:CGRectMake(0, 0, 948, 340)];
    numberPadView3.textField = _recoveryGoldPriceTextField;
    
    FPNumberPadView *numberPadView4 = [[FPNumberPadView alloc] initWithFrame:CGRectMake(0, 0, 948, 340)];
    numberPadView4.textField = _lossTextField;
    
//    FPNumberPadView *numberPadView5 = [[FPNumberPadView alloc] initWithFrame:CGRectMake(0, 0, 948, 340)];
//    numberPadView5.textField = _processFeeTextField;
    

    chengSeCodeArray=[NSMutableArray array];
    chengSeNameArray=[NSMutableArray array];
    oldChengSeCodeArray=[NSMutableArray array];
    oldChengSeArray=[NSMutableArray array];
    oldWeightArray=[NSMutableArray array];
    oldRecyclePriceArray=[NSMutableArray array];
    oldRealPriceArray=[NSMutableArray array];
    oldLossArray=[NSMutableArray array];
    oldPriceArray=[NSMutableArray array];
    CGRect frame=_oldMeterialViewContainer.frame;
    frame.origin.y=768;
    [_oldMeterialViewContainer setFrame:frame];
    [_oldMeterialAlphaView setBackgroundColor:[Global parseColor:WESTORE_TRANSCLUCENT]];
    [_oldMeterialAlphaView addTarget:self action:@selector(oldMeterialAlphaViewClick) forControlEvents:UIControlEventTouchUpInside];
    
    CGRect frame1=_chengSeViewContainer.frame;
    frame1.size.height=1;
    [_chengSeViewContainer setFrame:frame1];
    _chengSeViewContainer.hidden=YES;
    chengSeListIsOpen=NO;
    
    _oldMeterialAddRowBtn.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
    _oldMeterialAddRowBtn.layer.borderWidth= 1.0f;
    [_oldMeterialAddRowBtn addTarget:self action:@selector(addRowClick) forControlEvents:UIControlEventTouchUpInside];
    [_chengSeListBtn addTarget:self action:@selector(chengSeListBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
//    _oldMeterialTextView.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
//    _oldMeterialTextView.layer.borderWidth= 1.0f;
//    _oldMeterialTextView.layer.cornerRadius=3;
//  


}
-(void)chengSeListBtnClick
{
    
        if (chengSeListIsOpen) {
            _chengSeViewContainer.hidden=YES;
            [UIView animateWithDuration:0.5 animations:^{
                
                UIImage *closeImage=[UIImage imageNamed:@"jiantou_down.png"];
                [_chengSeListArrow setImage:closeImage];
                CGRect frame=_chengSeViewContainer.frame;
                
                frame.size.height=1;
                [_chengSeViewContainer setFrame:frame];
                
            } completion:^(BOOL finished){
                chengSeListIsOpen=NO;
            }];
            
        }
        else
        {
            [self requestChengSe];
            
            _chengSeViewContainer.hidden=NO;
            [UIView animateWithDuration:0.5 animations:^{
                UIImage *closeImage=[UIImage imageNamed:@"jiantou_upward.png"];
                
                
                [_chengSeListArrow setImage:closeImage];
                CGRect frame=_chengSeViewContainer.frame;
                
                frame.size.height=601;
                [_chengSeViewContainer setFrame:frame];
                
            } completion:^(BOOL finished){
                chengSeListIsOpen=YES;
            }];
            
        }

}
-(void)addRowClick
{
    [_weightTextField resignFirstResponder];
    [_recoveryGoldPriceTextField resignFirstResponder];
    [_lossTextField resignFirstResponder];
    
    if ([_lossTextField.text floatValue]>=0&&[_lossTextField.text floatValue]<100&&_weightTextField.text.length>0&&[_weightTextField.text floatValue]>0&&_recoveryGoldPriceTextField.text.length>0&&[_recoveryGoldPriceTextField.text floatValue]>0&&_chengSeTextField.text.length>0){
   // if (_lossTextField.text.length>0&&[_lossTextField.text floatValue]>0) {
        NSString *lossStr=[NSString stringWithFormat:@"%0.02f",[_lossTextField.text floatValue]];
        [oldLossArray addObject: lossStr ];
        float a=[_weightTextField.text floatValue]*[_recoveryGoldPriceTextField.text floatValue];
        float b=[_weightTextField.text floatValue]*[_recoveryGoldPriceTextField.text floatValue]*[_lossTextField.text floatValue]/100;
        NSString *priceStr=[NSString stringWithFormat:@"%0.02f",a-b];
        [oldPriceArray addObject:priceStr];
        [oldRealPriceArray addObject:priceStr];
        
        [oldChengSeArray addObject:_chengSeTextField.text];
        NSInteger codeInt=[chengSeNameArray indexOfObject:_chengSeTextField.text];
        [oldChengSeCodeArray addObject:[chengSeCodeArray objectAtIndex:codeInt]];
        

        [oldWeightArray addObject:_weightTextField.text];
        [oldRecyclePriceArray addObject:_recoveryGoldPriceTextField.text];
        
        float total=0.00f;
        for (int i=0; i<oldRealPriceArray.count; i++) {
            total=total+[[oldRealPriceArray objectAtIndex:i] floatValue];
        }
        
        float AvgPrice=total;
        oldMeterialTotalAmountFloat=total;
        NSString *AvgPriceStr=[Global floatConvertPercentile:AvgPrice];
        
        _oldMeterialTotalAmountLabel.text=AvgPriceStr;
        _weightTextField.text=@"";
        _chengSeTextField.text=@"";
        _recoveryGoldPriceTextField.text=@"";
        _lossTextField.text=@"";

    }
      else
    {
          if ([_weightTextField.text floatValue]<=0) {
            _weightTextField.text=@"";
            UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"请输入有效的克重" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
            [alert show];
        }
       else  if ([_recoveryGoldPriceTextField.text floatValue]<=0) {
             _recoveryGoldPriceTextField.text=@"";
            UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"请输入有效的回收金价" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
            [alert show];

        }
        else if ([_lossTextField.text floatValue]<=0||[_lossTextField.text floatValue]>100) {
            _lossTextField.text=@"";
            UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"请输入有效的损耗值" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
            [alert show];
        }
       
    
    }
    
    [_oldMeterialTableview reloadData];
    CGRect frame1=_oldMeterialTableview.frame;
    frame1.size.height=50*oldChengSeArray.count;
    _oldMeterialTableview.frame=frame1;
    
    
    [_oldMeterialScrollView setContentSize:CGSizeMake(0, _oldMeterialTableview.frame.origin.y+ _oldMeterialTableview.frame.size.height)];
    [_oldMeterialScrollView setScrollEnabled:YES];
}
-(void)oldMeterialAlphaViewClick
{
     [_oldMeterialScrollView setContentOffset:CGPointMake(0, 0)];
    [UIView animateWithDuration:0.5 animations:^{
        
        
        CGRect frame=_oldMeterialViewContainer.frame;
        
        frame.origin.y=768;
        [_oldMeterialViewContainer setFrame:frame];
        
    } completion:^(BOOL finished){
       
    }];
    CGRect frame=_cashierViewContainer.frame;
    
    frame.origin.y=0;
    [_cashierViewContainer setFrame:frame];

    
}
-(IBAction)priceDetail1ConfirmClick:(id)sender
{
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        [params setObject:@"" forKey:@"GoldPrice"];
        [params setObject:@"" forKey:@"GoldAmount"];
        [params setObject:@"" forKey:@"ProcessPrice"];
        [params setObject:@"" forKey:@"ProcessAmount"];
        [params setObject:@"" forKey:@"CutQty"];
          [params setObject:_discountRateTextField.text forKey:@"DisRate"];
        [params setObject:_discountTextField1.text forKey:@"DisAmount"];
        //[params setObject:_remarkTextView1.text forKey:@"Remark"];
        [params setObject:[shopCartCodeArray objectAtIndex:priceDetailCellTag] forKey:@"ItemCode"];
       //   NSLog(@"ccccc===%@",params);
        [HttpRequest requestData:@"Guide/EditPriceDetail" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            //  NSLog(@"serrr==%@",severDataDict.dataDict);
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    [UIView animateWithDuration:0.5 animations:^{
                        
                        CGRect frame=_priceDetailViewContainer1.frame;
                        
                        frame.origin.y=768;
                        [_priceDetailViewContainer1 setFrame:frame];
                        
                    } completion:^(BOOL finished){
                        
                    }];
                    
                    NSString *discountStr=[NSString stringWithFormat:@"%0.02f",priceDetail1DiscountValueFloat];
                    [shopCartSaleArray replaceObjectAtIndex:priceDetailCellTag withObject:discountStr];

                    NSIndexPath *indexPath1= [NSIndexPath indexPathForRow:priceDetailCellTag inSection:0];
                    UITableViewCell *cell = [_shopCartTableView cellForRowAtIndexPath:indexPath1];
                    ShopCartTableViewCell *shopCartCell=( ShopCartTableViewCell *)cell;
                    shopCartCell.salePriceLabel.text=_priceDetailtotalValueLabel1.text;
                    
                    float value=0.00f;
                    for (int i=0; i<shopCartSaleArray.count; i++) {
//                        NSIndexPath *indexPath1= [NSIndexPath indexPathForRow:i inSection:0];
//                        UITableViewCell *cell = [_shopCartTableView cellForRowAtIndexPath:indexPath1];
//                        ShopCartTableViewCell *shopCartCell=( ShopCartTableViewCell *)cell;
//                        value=value+  [shopCartCell.salePriceLabel.text floatValue];
                        value=value+[[shopCartSaleArray objectAtIndex:i] floatValue];
                        
                    }
                    _totalResultLabel.text=[NSString stringWithFormat:@"%0.02f",value];
                    
                    _discountTextField1.text=@"";
                    _discountLabel1.text=@"";
//                    _remarkTextView1.text=@"";
//                    _textviewImage1.hidden=NO;
//                    _textviewLabel1.hidden=NO;
                    _priceDetailtotalValueLabel1.text=@"";
                    
                    
                    
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                        
                        if (_timer!=nil) {
                            [_timer invalidate];
                            _timer=nil;
                        }
                      [Global loginViewController:self noteStr:requestResultStr];
                      //  [Global loginViewController:self];
                    }

                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
        
    }

//    [shopCartSaleArray replaceObjectAtIndex:priceDetailCellTag withObject:<#(id)#>];
//    
}
-(void)updateDiscountValueLabel:(UITextField *)sender
{
   
//    NSIndexPath *indexPath1= [NSIndexPath indexPathForRow:priceDetailCellTag inSection:0];
//    UITableViewCell *cell = [_shopCartTableView cellForRowAtIndexPath:indexPath1];
//    ShopCartTableViewCell *shopCartCell=( ShopCartTableViewCell *)cell;
   // shopCartCell.salePriceLabel.text=_priceDetailtotalValueLabel.text;
    if (sender==_discountTextField1) {
    
    if ([sender.text floatValue]<=[[shopCartMarketArray objectAtIndex:priceDetailCellTag] floatValue]) {
       priceDetail1DiscountValueFloat=[[shopCartMarketArray objectAtIndex:priceDetailCellTag] floatValue]-[sender.text floatValue];
        _priceDetailtotalValueLabel1.text=[Global floatConvertPercentile:priceDetail1DiscountValueFloat];
        _discountRateTextField.text=[NSString stringWithFormat:@"%0.02f",(1-([sender.text floatValue]/[[shopCartMarketArray objectAtIndex:priceDetailCellTag] floatValue]))*100];
        
        _discountLabel1.text=[NSString stringWithFormat:@"-¥%0.02f",[sender.text floatValue]];
//        if ([_discountRateTextField.text floatValue]==0) {
//             _discountRateTextField.text=@"";
//        }
    }
    else
    {
        [_discountTextField1 resignFirstResponder];
        [UIView animateWithDuration:0.5 animations:^{
            
            CGRect frame=_priceDetailViewContainer1.frame;
            
            frame.origin.y=0;
            [_priceDetailViewContainer1 setFrame:frame];
            
        } completion:^(BOOL finished){
            
        }];
        
         _priceDetailtotalValueLabel1.text=[Global floatConvertPercentile:[[shopCartMarketArray objectAtIndex:priceDetailCellTag] floatValue]];

        UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"折扣金额大于支付金额，请重新输入" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alert show];
        sender.text=@"";
        _discountLabel1.text=@"";
        _discountRateTextField.text=@"";
    }
    }
    if (sender==_discountRateTextField) {
        if (0<[sender.text floatValue]&&[sender.text floatValue]<=100)
        {
            _discountTextField1.text=[NSString stringWithFormat:@"%0.02f",[[shopCartMarketArray objectAtIndex:priceDetailCellTag] floatValue]*(1-[sender.text floatValue]/100)];
            _discountLabel1.text=[NSString stringWithFormat:@"-¥%0.02f",[_discountTextField1.text floatValue]];
            priceDetail1DiscountValueFloat=[[shopCartMarketArray objectAtIndex:priceDetailCellTag] floatValue]-[_discountTextField1.text floatValue];
            _priceDetailtotalValueLabel1.text=[Global floatConvertPercentile:priceDetail1DiscountValueFloat];
        }
        else if([sender.text floatValue]>100)
        {
            UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"折扣率大于100%，请重新输入" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
            [alert show];
            _discountTextField1.text=@"";
            _discountRateTextField.text=@"";
            _discountLabel1.text=@"";
        }
        else if([sender.text floatValue]==0)
        {
           // UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"无效输入" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
            //[alert show];
            _discountTextField1.text=@"";
            _discountRateTextField.text=@"";
            _discountLabel1.text=@"";
            _priceDetailtotalValueLabel1.text=[Global floatConvertPercentile:[[shopCartMarketArray objectAtIndex:priceDetailCellTag] floatValue]];
        }


    }
}
-(void)updateValueLabel:(UITextField *)sender
{
     balanceAmountFloat=cashierAmountFloat-[_integralTextField.text floatValue]-[_deductibleTextField.text floatValue]-[_oldMeterialTextField.text floatValue];
    
    NSString *AvgPriceStr=[Global floatConvertPercentile:balanceAmountFloat];
    _balancePayLabel.text=AvgPriceStr;
   //  NSLog(@"balanceAmountFloat====%f",balanceAmountFloat);
    
    
   }

-(void)cashierAlphaViewClick1
{
    [_integralTextField resignFirstResponder];
    [_deductibleTextField resignFirstResponder];
    [_cashierTextView resignFirstResponder];
   
    [_cashierSrollView setContentOffset:CGPointMake(0, 0)];
     _cashierSearchMemberTextField.text=@"";
    _memberGradeLabel.hidden=YES;
    _memberGradeTagLabel.hidden=YES;
    //_memberSexImage.hidden=YES;
    _memberIntegralLabel.hidden=YES;
    _memberIntegralTagLabel.hidden=YES;
    
    CGRect frame=_cashierSrollView.frame;
    
    frame.origin.y=0;
    [_cashierSrollView setFrame:frame];
    
    [UIView animateWithDuration:0.5 animations:^{
        
       
        CGRect frame=_cashierViewContainer.frame;
        
        frame.origin.y=768;
        [_cashierViewContainer setFrame:frame];
        
      

        
    } completion:^(BOOL finished){
        isOpened=NO;
    }];

}
-(void)selectGuideBtnClick
{
    
    if (isOpened) {
        _guideListViewContainer.hidden=YES;
        [UIView animateWithDuration:0.5 animations:^{
            
            UIImage *closeImage=[UIImage imageNamed:@"jiantou_down.png"];
            [_guideListArrowImage setImage:closeImage];
            CGRect frame=_guideListViewContainer.frame;
            
            frame.size.height=1;
            [_guideListViewContainer setFrame:frame];
            
        } completion:^(BOOL finished){
            isOpened=NO;
        }];
        
    }
    else
    {
        [self requestGuideList];
        _guideListViewContainer.hidden=NO;
        [UIView animateWithDuration:0.5 animations:^{
            UIImage *closeImage=[UIImage imageNamed:@"jiantou_upward.png"];
            
            
            [_guideListArrowImage setImage:closeImage];
            CGRect frame=_guideListViewContainer.frame;
//            if(_cashierLastView.frame.origin.y+_cashierLastView.frame.size.height>657)
//            {
//            frame.size.height=_cashierLastView.frame.origin.y+_cashierLastView.frame.size.height;
//            }
//            else
//            {
                frame.size.height=657;
            //}
            [_guideListViewContainer setFrame:frame];
            
        } completion:^(BOOL finished){
            isOpened=YES;
        }];
        
    }
    
}
-(void)requestGuideList
{
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        [HttpRequest requestData:@"Guide/GuideList" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    [guideCodeArray removeAllObjects];
                    [guideNameArray removeAllObjects];
                    mGuidesArray=[severDataDict.dataDict objectForKey:@"DataLine"];
                    for (int i=0; i<mGuidesArray.count; i++) {
                        [guideCodeArray addObject:[[mGuidesArray objectAtIndex:i] objectForKey:@"UserCode"]];
                        [guideNameArray addObject:[[mGuidesArray objectAtIndex:i] objectForKey:@"UserName"]];
                    }
                    // NSLog(@"guideCodeArray==%@",guideCodeArray);
                    //
                    [_guideListTableView reloadData];
                    
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                        
                        if (_timer!=nil) {
                            [_timer invalidate];
                            _timer=nil;
                        }
                    [Global loginViewController:self noteStr:requestResultStr];
                    //    [Global loginViewController:self];
                    }

                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
        
    }
    
}
-(void)cashierDetailBtnClick
{
    CGRect viewFrame=_cashierViewContainer.frame;
    viewFrame.origin.y=768;
    _cashierViewContainer.frame=viewFrame;
    //_chengSeTextField.text=@"";
  // _chengSeTextField.placeholder=@"请选择成色";
   // _weightTextField.text=@"";
 //   _weightTextField.placeholder=@"请输入克重";
    //_recoveryGoldPriceTextField.text=@"";
   // _recoveryGoldPriceTextField.placeholder=@"请输入回收金价";
  //  _lossTextField.text=@"";
   // _lossTextField.placeholder=@"请输入损耗";
  //  _oldMeterialTextView.text=@"";
   // _oldMeterialTextViewImage.hidden=NO;
    //_oldMeterialTextViewLabel.hidden=NO;

    
//    [oldChengSeArray removeAllObjects];
//    [oldChengSeCodeArray removeAllObjects];
//    [oldWeightArray removeAllObjects];
//    [oldRecyclePriceArray removeAllObjects];
//    [oldLossArray removeAllObjects];
//    [oldPriceArray removeAllObjects];
//    [_oldMeterialTableview reloadData];
//    [self requestOldMeterial];
//    _oldMeterialTotalAmountLabel.text=@"";
    [UIView animateWithDuration:0.3 animations:^{
        CGRect viewFrame=_oldMeterialViewContainer.frame;
        viewFrame.origin.y=0;
        _oldMeterialViewContainer.frame=viewFrame;
    } completion:^(BOOL finished){
        
    }];

}
//- (void)getAuthToken
//{
//    // 先取token, 做预下单时需要用到. 可以放在第三方登录之后.
//    [[CBSDK sharedInstance] authWithAPIKey:API_KEY resultBlock:^(NSString *token, NSString *errorCode, NSString *errorMessage) {
//        if (errorCode == nil) {
//            self.TPFToken = token;
//          //  [self textViewAppendFormat:@"得到 TPFToken:%@\n", token];
//        } else {
//           // [self textViewAppendFormat:@"errorCode:%@, errorMessage:%@\n", errorCode, errorMessage];
//        }
//    }];
//}
//


-(IBAction)cashierConfirmClick:(id)sender
{
    _isLoad=@"Y";
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableArray *mDocumentLine=[NSMutableArray array];
        //        //        NSLog(@"findSkuAllCountArray===%@",findSkuAllCountArray);
        for (int i=0; i<oldWeightArray.count; i++) {
            NSString *weightStr1 = [oldWeightArray objectAtIndex:i];
            NSString *chengSeCodeStr=[oldChengSeCodeArray objectAtIndex:i];
            NSString *lossStr=[oldLossArray objectAtIndex:i];
            NSString *recycleStr=[oldRecyclePriceArray objectAtIndex:i];
             NSString *realPriceStr=[oldRealPriceArray objectAtIndex:i];
            
            NSMutableDictionary *dic = [NSMutableDictionary dictionary];
            
            [dic setValue:recycleStr forKey:@"GoldPrice"];
            [dic setValue:lossStr forKey:@"LossRate"];
            [dic setValue:chengSeCodeStr forKey:@"FinenessCode"];
            [dic setValue:weightStr1 forKey:@"Gram"];
            [dic setValue:realPriceStr forKey:@"DealLineTotal"];
            [mDocumentLine addObject:dic];
        }

        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        
       // [params setObject:_orderNumberLabel.text forKey:@"DocNum"];
        [params setObject:guideCodeStr forKey:@"GuideCode"];
        [params setObject:memberCodeStr forKey:@"MemberCode"];
       // [params setObject:@"Order" forKey:@"DocType"];
        [params setObject:_integralTextField.text forKey:@"IntegralAmount"];
        [params setObject:_deductibleTextField.text forKey:@"Rebate"];
        [params setObject:entryString forKey:@"DepositEntry"];
        [params setObject:_depositText.text forKey:@"Subscription"];
        [params setObject:_cashierTextView.text forKey:@"Remark"];
        [params setObject:mDocumentLine forKey:@"DataLine"];
     //    NSLog(@"lllllARAM===%@",params);
        [HttpRequest requestData:@"Guide/ShopCartBuying" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    [Global showTextHudSub:requestResultStr view:self.view];
//                    [UIView animateWithDuration:0.3 animations:^{
//                        
//                        CGRect viewFrame=_cashierViewContainer.frame;
//                        viewFrame.origin.y=768;
//                        _cashierViewContainer.frame=viewFrame;
//                    } completion:^(BOOL finished){
//                        
//                    }];
                    
                    _totalResultLabel.text=@" ";
                    _shopCartTotalLabel.text=[NSString stringWithFormat:@"购物车共有%d件产品",0];
                    [shopCartAllArray removeAllObjects];
                    [shopCartImageArray removeAllObjects];
                    [shopCartNameArray removeAllObjects];
                    [shopCartDocTypeArray removeAllObjects];
                    [shopCartSaleArray removeAllObjects];
                    [shopCartMarketArray removeAllObjects];
                    [selectedCountArray removeAllObjects];
                    [selectedCodeArray removeAllObjects];
                    [shopCartCodeArray removeAllObjects];
                    [shopCartWeightArray removeAllObjects];
                    [shopCartAddressArray removeAllObjects];
                    [shopCartAttributeArray removeAllObjects];
                    [_shopCartTableView reloadData];
                    
                    [oldChengSeArray removeAllObjects];
                    [oldChengSeCodeArray removeAllObjects];
                    [oldWeightArray removeAllObjects];
                    [oldRecyclePriceArray removeAllObjects];
                    [oldLossArray removeAllObjects];
                    [oldPriceArray removeAllObjects];
                    [oldRealPriceArray removeAllObjects];
                    [_oldMeterialTableview reloadData];
                   // [self requestOldMeterial];
                    _oldMeterialTotalAmountLabel.text=@"";
                    oldMeterialTotalAmountFloat=0.0;
                    
                    if (cashierVC.view!=nil) {
                        
                        [cashierVC removeFromParentViewController];
                        [cashierVC.view removeFromSuperview];
                        
                    }
                    cashierVC=[[CashierViewController alloc] init];
                    cashierVC.delegate=self;
                    cashierVC.docTypeStr=@"Order";
                    cashierVC.docNumStr=[severDataDict.dataDict objectForKey:@"DocNum"];
                    cashierVC.view.frame = CGRectMake(0,
                                                      0,
                                                      self.view.bounds.size.width,
                                                      self.view.bounds.size.height);
                    
                    [self addChildViewController:cashierVC];
                    [self.view addSubview:cashierVC.view];
                    [self.view bringSubviewToFront:cashierVC.view];
                    
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                        
                        if (_timer!=nil) {
                            [_timer invalidate];
                            _timer=nil;
                        }
                      [Global loginViewController:self noteStr:requestResultStr];
                      //  [Global loginViewController:self];
                    }

                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
        
    }
  
    
}
//cashierViewcontrollerDelegate
-(void)CashierAlphaViewClick
{
       if ([self.delegate respondsToSelector:@selector(shopcartCashierFinish)]) {
        
        [self.delegate shopcartCashierFinish];
    }
    
}
-(void)CashierSuccess
{
    if (cashierVC.view!=nil) {
        
        [cashierVC removeFromParentViewController];
        [cashierVC.view removeFromSuperview];
        
    }
    [UIView animateWithDuration:0.3 animations:^{
        
        CGRect viewFrame=_cashierViewContainer.frame;
        viewFrame.origin.y=768;
        _cashierViewContainer.frame=viewFrame;
    } completion:^(BOOL finished){
        
    }];
    
    if ([self.delegate respondsToSelector:@selector(shopcartCashierFinish)]) {
        
        [self.delegate shopcartCashierFinish];
    }


}

-(void)hzSuccess
{
    _totalResultLabel.text=@" ";
    _shopCartTotalLabel.text=[NSString stringWithFormat:@"购物车共有%d件产品",0];
    [shopCartAllArray removeAllObjects];
    [shopCartImageArray removeAllObjects];
    [shopCartNameArray removeAllObjects];
    [shopCartDocTypeArray removeAllObjects];
    [shopCartSaleArray removeAllObjects];
    [shopCartMarketArray removeAllObjects];
    [shopCartAttributeArray removeAllObjects];
    [selectedCountArray removeAllObjects];
    [selectedCodeArray removeAllObjects];
    [shopCartCodeArray removeAllObjects];
    [shopCartWeightArray removeAllObjects];
    [shopCartAddressArray removeAllObjects];
    [_shopCartTableView reloadData];
    
    [UIView animateWithDuration:0.3 animations:^{
        
        CGRect viewFrame=_cashierViewContainer.frame;
        viewFrame.origin.y=768;
        _cashierViewContainer.frame=viewFrame;
    } completion:^(BOOL finished){
        
    }];
    
    
    if ([self.delegate respondsToSelector:@selector(shopcartCashierFinish)]) {
        
        [self.delegate shopcartCashierFinish];
    }

}

-(IBAction)backClick:(id)sender
{
    if ([self.delegate respondsToSelector:@selector(shopCartBackClick)]) {
        
        [self.delegate shopCartBackClick];
    }

}
-(IBAction)oldMeterialDetailClick:(id)sender
{
     [_oldMeterialScrollView setContentOffset:CGPointMake(0, 0)];
  //  [_oldMeterialTextView resignFirstResponder];
    

   // if ([_oldMeterialTotalAmountLabel.text floatValue]<[_cashierAmountLabel.text floatValue]) {
    if (oldLossArray.count>0) {
    
        [UIView animateWithDuration:0.3 animations:^{
        _oldMeterialTextField.text=[NSString stringWithFormat:@"%0.02f",oldMeterialTotalAmountFloat];//_oldMeterialTotalAmountLabel.text;
                        
        float decutibleFloat=[_integralTextField.text floatValue]+[_depositText.text floatValue]+[_deductibleTextField.text floatValue]+[_oldMeterialTextField.text floatValue];
            _decutibleLabel.text=[Global floatConvertPercentile:decutibleFloat];

        _cashierLastTotalLabel.text=[Global floatConvertPercentile:cashierAmountFloat-decutibleFloat];
                        
        balanceAmountFloat=cashierAmountFloat-oldMeterialTotalAmountFloat-[_integralTextField.text floatValue]-[_deductibleTextField.text floatValue];//[_oldMeterialTotalAmountLabel.text floatValue];
                        
                      
        NSString *AvgPriceStr=[Global floatConvertPercentile:balanceAmountFloat];
                        _balancePayLabel.text=AvgPriceStr;

                        CGRect viewFrame=_oldMeterialViewContainer.frame;
                        viewFrame.origin.y=768;
                        _oldMeterialViewContainer.frame=viewFrame;
                    } completion:^(BOOL finished){
                        
                    }];

        CGRect viewFrame=_cashierViewContainer.frame;
        viewFrame.origin.y=0;
        _cashierViewContainer.frame=viewFrame;
        
        _chengSeTextField.text=@"";
        _weightTextField.text=@"";
        _recoveryGoldPriceTextField.text=@"";
        _lossTextField.text=@"";
       // oldMeterialTotalAmountFloat=0.0;
        
    }
    else
    {
        UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"旧料明细为空,是否保存?" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        alert.delegate=self;
        alert.tag=100;
        [alert show];
    }
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    // the user clicked OK
    if (alertView.tag==100) {
        
        if (buttonIndex == 0)
        {
                if ([Global getLoginToken].length>0) {
                    
                    [UIView animateWithDuration:0.3 animations:^{
                    _oldMeterialTextField.text=[NSString stringWithFormat:@"%0.02f",oldMeterialTotalAmountFloat];//_oldMeterialTotalAmountLabel.text;
                                    
                    balanceAmountFloat=cashierAmountFloat-oldMeterialTotalAmountFloat-[_integralTextField.text floatValue]-[_deductibleTextField.text floatValue];//[_oldMeterialTotalAmountLabel.text floatValue];
                                    
                        NSString *AvgPriceStr=[Global floatConvertPercentile:balanceAmountFloat];
                    _balancePayLabel.text=AvgPriceStr;
                                    
                    CGRect viewFrame=_oldMeterialViewContainer.frame;
                                    viewFrame.origin.y=768;
                                    _oldMeterialViewContainer.frame=viewFrame;
                                } completion:^(BOOL finished){
                                    
                                }];
                                
                   CGRect viewFrame=_cashierViewContainer.frame;
                   viewFrame.origin.y=0;
                   _cashierViewContainer.frame=viewFrame;
                    
                    _chengSeTextField.text=@"";
                    _weightTextField.text=@"";
                    _recoveryGoldPriceTextField.text=@"";
                    _lossTextField.text=@"";

                
            }
        }
      
    }
    else if (alertView.tag==1000)
    {
        if (buttonIndex == 0)
        {
//        if ((_depositView.frame.origin.y+_depositView.frame.size.height+_cashierSrollView.contentOffset.y+352>768)) {
            
            
            [UIView animateWithDuration:0.3 animations:^{
                CGRect viewFrame=_cashierViewContainer.frame;
                viewFrame.origin.y=-(_depositView.frame.origin.y+_depositView.frame.size.height-_cashierSrollView.contentOffset.y+355-768);
                _cashierViewContainer.frame=viewFrame;
            } completion:^(BOOL finished){
                
            }];
        }
    }
  //  }
}

-(IBAction)shopCartCashierClick:(id)sender
{
    _guideListViewContainer.hidden=YES;
   
        
        UIImage *closeImage=[UIImage imageNamed:@"jiantou_down.png"];
        [_guideListArrowImage setImage:closeImage];
        CGRect frame=_guideListViewContainer.frame;
        
        frame.size.height=1;
        [_guideListViewContainer setFrame:frame];
    
        isOpened=NO;
    

    selectDepositCellTagStr=@"";
   
    _cashierTextView.text=@"";
    _cashierTextViewImage.hidden=NO;
    _cashierTextViewLabel.hidden=NO;
    _depositText.text=@"";
    _decutibleLabel.text=@"";
    _integralTextField.text=@"";
    _oldMeterialTextField.text=@"";
    _deductibleTextField.text=@"";
    if (shopCartImageArray.count>0) {
        
        [oldChengSeArray removeAllObjects];
        [oldChengSeCodeArray removeAllObjects];
        [oldWeightArray removeAllObjects];
        [oldRecyclePriceArray removeAllObjects];
        [oldLossArray removeAllObjects];
        [oldPriceArray removeAllObjects];
        [oldRealPriceArray removeAllObjects];
        [_oldMeterialTableview reloadData];
        // [self requestOldMeterial];
        _oldMeterialTotalAmountLabel.text=@"";

        
        _cashierTextView.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
        _cashierTextView.layer.borderWidth= 1.0f;
        _cashierTextView.layer.cornerRadius=3;
        
    _guideNameLabel.text=[Global getGuideNameStr];
        
    [Global resizeForLable:_guideNameLabel WithText:_guideNameLabel.text parentView:self.view];
    CGRect frameK=_guideNameLabel.frame;
    frameK.origin.x=_guideListArrowImage.frame.origin.x-frameK.size.width-5;
    _guideNameLabel.frame=frameK;

    guideCodeStr=[Global getGuideCodeStr];
    UIImage *closeImage=[UIImage imageNamed:@"jiantou_down.png"];
    [_guideListArrowImage setImage:closeImage];
    memberCodeStr=@"";
    _memberAndPhoneLabel.text=@"";
    _orderNumberLabel.text=@"";
    _cashierAmountLabel.text=@"";
    _integralTextField.text=@"";
    _deductibleTextField.text=@"";
    _oldMeterialTextField.text=@"";
    _balancePayLabel.text=@"";
    balanceAmountFloat=0.0;
    entryString=@"";
    integralAvailabalStr=@"";
    _integralAvailabelLabel.text=[NSString stringWithFormat:@"可抵  ¥0.00"];
     // [self getAuthToken];
//    if ([Global getLoginToken].length>0) {
//        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
//        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
//        [params setObject:[Global getLoginToken] forKey:@"Token"];
//                // NSLog(@"paramsLIST====%@",params);
//        [HttpRequest requestData:@"Guide/ShopCartBuying" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
//            if (isSuccess) {
//                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
//                    [Global hideProgressHUDInternal:self.view];
//                    
//                      float AvgPrice=[[severDataDict.dataDict objectForKey:@"Total"] floatValue];
//                     cashierAmountFloat=[[severDataDict.dataDict objectForKey:@"Total"] floatValue];
//                  //  _cashierAmountLabel.text=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"Total"] floatValue]];
//                    NSString *AvgPriceStr=[Global floatConvertPercentile:AvgPrice];
//                    
//                    _cashierAmountLabel.text=[NSString stringWithFormat:@"%@",AvgPriceStr];
//                    _orderNumberLabel.text=[severDataDict.dataDict objectForKey:@"DocNum"];
//                   // _balancePayLabel.text=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"Total"] floatValue]];
//                    balanceAmountFloat=[[severDataDict.dataDict objectForKey:@"Total"] floatValue];
//                    NSString *AvgPriceStr1=[Global floatConvertPercentile:balanceAmountFloat];
//                    _balancePayLabel.text=AvgPriceStr1;
//                    
                    [UIView animateWithDuration:0.3 animations:^{
                        CGRect viewFrame=_cashierViewContainer.frame;
                        viewFrame.origin.y=0;
                        _cashierViewContainer.frame=viewFrame;
                    } completion:^(BOOL finished){
                        
                    }];
                   [_cashierListTableView reloadData];
                  CGRect rectTable=_cashierListTableView.frame;
                  rectTable.size.height=shopCartCodeArray.count*120;
                 _cashierListTableView.frame=rectTable;
        
                 CGRect rectDecutible=_decutibleView.frame;
                 rectDecutible.origin.y=_cashierListTableView.frame.size.height+_cashierListTableView.frame.origin.y+20;
                _decutibleView.frame=rectDecutible;
        
               CGRect rectLast=_cashierLastView.frame;
               rectLast.origin.y=_decutibleView.frame.size.height+_decutibleView.frame.origin.y+20;
              _cashierLastView.frame=rectLast;

        float cashierTotalMoney=0.0;
        for (int i=0; i<shopCartSaleArray.count; i++) {
            cashierTotalMoney=cashierTotalMoney+ [[shopCartSaleArray objectAtIndex:i] floatValue];
        }
        
        float cashierTotalWeight=0.0;
        for (int i=0; i<shopCartWeightArray.count; i++) {
            cashierTotalWeight=cashierTotalWeight+ [[shopCartWeightArray objectAtIndex:i] floatValue];
        }
        
        _cashierTotalLabel.text=[Global floatConvertPercentile:cashierTotalMoney];
        cashierAmountFloat=cashierTotalMoney;
        _cashierLastTotalLabel.text=_cashierTotalLabel.text;
       // [self resizeLabel:_cashierTotalLabel];
        [Global resizeForLable:_cashierTotalLabel WithText:_cashierTotalLabel.text parentView:self.view];
        _cashierInfoLabel.text=[NSString stringWithFormat:@"共%d件,%0.02fg )",shopCartWeightArray.count,cashierTotalWeight];
       // [self resizeLabel:_cashierInfoLabel];
        [Global resizeForLable:_cashierInfoLabel WithText:_cashierInfoLabel.text parentView:self.view];
        
        CGRect rectI=_cashierInfoLabel.frame;
        rectI.origin.x=_cashierTotalLabel.frame.size.width+_cashierTotalLabel.frame.origin.x+10;
        _cashierInfoLabel.frame=rectI;

        
        [_cashierSrollView setContentSize:CGSizeMake(0, _cashierLastView.frame.origin.y+ _cashierLastView.frame.size.height+10)];
        [_cashierSrollView setScrollEnabled:YES];
        
        
//
//
//                }
//                else
//                {
//                    [Global hideProgressHUDInternal:self.view];
//                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
//                    //  [Global showTextHud:requestResultStr view:self.view];
//                    [Global showTextHudSub:requestResultStr view:self.view];
//                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
//                        
//                        if (_timer!=nil) {
//                            [_timer invalidate];
//                            _timer=nil;
//                        }
//                      [Global loginViewController:self noteStr:requestResultStr];
//                      ///  [Global loginViewController:self];
//                    }
//
//                }
//            }
//            else
//            {
//                //[Global hideProgressHUDInternal:self.view];
//                [Global showTextHudSub:@"连接失败" view:self.view];
//            }
//        }];
//        
//    }
    }
    else
    {
        UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"购物车内没有商品" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alert show];

    }
}
-(IBAction)selectDepositBtnClick:(id)sender
{
     _isLoad=@"N";
    if (memberCodeStr.length>0) {
        
   
    if (selectDepositVC.view!=nil) {
        
        [selectDepositVC removeFromParentViewController];
        [selectDepositVC.view removeFromSuperview];
        
    }
    selectDepositVC=[[SelectDepositViewController alloc] init];
    selectDepositVC.delegate=self;
        selectDepositVC.cellTag=selectDepositCellTagStr;
    selectDepositVC.memberAndPhoneStr=_memberAndPhoneLabel.text;
    selectDepositVC.gradeStr=_memberGradeLabel.text;
    selectDepositVC.integralStr=_memberIntegralLabel.text;
    selectDepositVC.memberCodeStr=memberCodeStr;

    selectDepositVC.view.frame = CGRectMake(0,
                                          0,
                                          self.view.bounds.size.width,
                                          self.view.bounds.size.height);
    
    [self addChildViewController:selectDepositVC];
    [self.view addSubview:selectDepositVC.view];
    }
    else
    {
        UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"请先选择会员" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alert show];
    }
    
 
}
#pragma mark SelectDepositViewControllerDelegate
-(void)selectDepositAlphaViewClick
{
    if (selectDepositVC.view!=nil) {
        
        [selectDepositVC removeFromParentViewController];
        [selectDepositVC.view removeFromSuperview];
        
    }

}
-(void)depositConfirmSelectBtnClick:(NSString *)entryStr depositAmoutStr:(NSString *)depositAmountStr cellTagStr:(NSString *)cellTagStr

{
    _isLoad=@"N";
    [_cashierListTableView reloadData];
    if (selectDepositVC.view!=nil) {
        
        [selectDepositVC removeFromParentViewController];
        [selectDepositVC.view removeFromSuperview];
        
    }
    selectDepositCellTagStr=cellTagStr;
    _depositText.text=depositAmountStr;
    float decutibleFloat=[_integralTextField.text floatValue]+[_depositText.text floatValue]+[_deductibleTextField.text floatValue]+[_oldMeterialTextField.text floatValue];
    _decutibleLabel.text=[Global floatConvertPercentile:decutibleFloat];
    
     _cashierLastTotalLabel.text=[Global floatConvertPercentile:cashierAmountFloat-decutibleFloat];

    entryString=entryStr;
    CGRect viewFrame=_cashierViewContainer.frame;
    viewFrame.origin.y=0;
    _cashierViewContainer.frame=viewFrame;
}
-(void) loadProductNextPage:(NSUInteger)oldPageNum {
    if(oldPageNum!=0 && _productTotalCount<=shopCartImageArray.count)
        return;
    if(oldPageNum == 0){
        [shopCartImageArray removeAllObjects];
        [_shopCartTableView reloadData];
    }
   _productPageIndex=oldPageNum+1;
    [self requestShopCartList: _productPageIndex pageSize:6];
}

-(void)requestShopCartList:(NSUInteger)pageIndex pageSize:(NSUInteger)pageSize
{
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        NSNumber *pageSizeNumber = [NSNumber numberWithInteger:pageSize];
        NSNumber *pageIndexNumber = [NSNumber numberWithInteger:pageIndex];
//        NSString *pageSizeStr=[NSString stringWithFormat:@"%d",pageSize];
//        NSString *pageIndexStr=[NSString stringWithFormat:@"%d",pageIndex];
        
        [params setObject:pageSizeNumber forKey:@"PageSize"];
        [params setObject:pageIndexNumber forKey:@"PageIndex"];
       // NSLog(@"paramsLIST====%@",params);
        [HttpRequest requestData:@"Guide/ShopCartList" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
//                    NSLog(@"shopcartlist===%@",severDataDict.dataDict);
                    _productTotalCount=[[severDataDict.dataDict objectForKey:@"TotalCount"] integerValue];
                    _shopCartTotalLabel.text=[NSString stringWithFormat:@"购物车共有%d件产品",_productTotalCount];
                   
                    if (_productTotalCount%6!=0) {
                        _productTotalPage=_productTotalCount/6+1;
                    }
                    else if (_productTotalCount%6==0)
                    {
                        _productTotalPage=_productTotalCount/6;
                    }
                   
                     shopCartListArray=[severDataDict.dataDict objectForKey:@"DataLine"];
                 //   int total=0;
                    if ( shopCartListArray.count>0) {
                        for (int i=0; i< shopCartListArray.count; i++) {
                            [shopCartAllArray addObject:[shopCartListArray objectAtIndex:i]];
                            [shopCartNameArray addObject:[[shopCartListArray objectAtIndex:i] objectForKey:@"ItemName"]];
                            [shopCartDocTypeArray addObject:[[shopCartListArray objectAtIndex:i] objectForKey:@"TypeName"]];
                            [shopCartMarketArray addObject:[[shopCartListArray objectAtIndex:i] objectForKey:@"MarketPrice"]];
                            [shopCartAttributeArray addObject:[[shopCartListArray objectAtIndex:i] objectForKey:@"Attributes"]];
                            
                            [shopCartSaleArray addObject:[[shopCartListArray objectAtIndex:i] objectForKey:@"SalePrice"]];
//                            if ([[shopCartListArray objectAtIndex:i] objectForKey:@"SalePrice"]!=[NSNull null] ) {
//                                
//                          
//                            total=total+[[[shopCartListArray objectAtIndex:i] objectForKey:@"SalePrice"] integerValue];
//                            }
                            [shopCartImageArray addObject:[[shopCartListArray objectAtIndex:i] objectForKey:@"ImageUrl"]];
                            [shopCartCodeArray addObject:[[shopCartListArray objectAtIndex:i] objectForKey:@"ItemCode"]];
                           
                            [shopCartAddressArray addObject:[[shopCartListArray objectAtIndex:i] objectForKey:@"WhsName"]];
                            [shopCartWeightArray addObject:[[shopCartListArray objectAtIndex:i] objectForKey:@"Gram"]];
                            [shopCartAttributeArray addObject:[[shopCartListArray objectAtIndex:i] objectForKey:@"Attributes"]];
                           //   NSLog(@"44889900===%@",[[shopCartListArray objectAtIndex:i] objectForKey:@"SalePrice"]);
                        }
                    }
                 
                    float AvgPrice=[[severDataDict.dataDict objectForKey:@"Amount"] floatValue];
                    NSString *AvgPriceStr=[Global floatConvertPercentile:AvgPrice];
                   // NSLog(@"AvgPrice===%f",AvgPrice);
                    _totalResultLabel.text=[NSString stringWithFormat:@"¥%@",AvgPriceStr];
                    [_shopCartTableView reloadData];

                    
                }
                else
                {
                     [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                        
                        if (_timer!=nil) {
                            [_timer invalidate];
                            _timer=nil;
                        }
                     [Global loginViewController:self noteStr:requestResultStr];
                     //   [Global loginViewController:self];
                    }

                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
        
    }
}
- (void)viewDidLoad {
    [super viewDidLoad];
    //NSMutableDictionary
    //totalResultValue=0;
    //  _sea
      // Do any additional setup after loading the view from its nib.
}
-(void)clearAllBtnClick:(id)sender
{
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        [HttpRequest requestData:@"Guide/DeleteShopCart" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    [shopCartAllArray removeAllObjects];
                    [shopCartImageArray removeAllObjects];
                    [shopCartNameArray removeAllObjects];
                    [shopCartDocTypeArray removeAllObjects];
                    [shopCartSaleArray removeAllObjects];
                    [shopCartMarketArray removeAllObjects];
                    [selectedCountArray removeAllObjects];
                    [selectedCodeArray removeAllObjects];
                    [shopCartCodeArray removeAllObjects];
                    [shopCartWeightArray removeAllObjects];
                    [shopCartAddressArray removeAllObjects];
                    [shopCartAttributeArray removeAllObjects];
                    [_shopCartTableView reloadData];
                     _totalResultLabel.text=[NSString stringWithFormat:@"¥%d",0];
                      _shopCartTotalLabel.text=[NSString stringWithFormat:@"购物车共有%d件产品",0];
                    
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                        
                        if (_timer!=nil) {
                            [_timer invalidate];
                            _timer=nil;
                        }
                     [Global loginViewController:self noteStr:requestResultStr];
                      //  [Global loginViewController:self];
                    }

                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
        
    }

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
//    NSMutableArray *codeArrays = [NSMutableArray arrayWithArray:[shopCartData objectForKey:@"PRODUCTCODE"]];
//    return [codeArrays count];
    if (tableView==_searchMemberTableView) {
        return memberCodeArray.count;
    }

   else if (tableView ==_shopCartTableView||tableView==_cashierListTableView) {
        return shopCartImageArray.count;
    }
    else if(tableView==_guideListTableView )
    {
         return guideCodeArray.count;
    }
    else if(tableView==_chengSeTableView)
    {
        return chengSeNameArray.count;
    }
    else
        return oldChengSeArray.count;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(tableView==_shopCartTableView||tableView==_cashierListTableView)
        return 120.0f;
    else if(tableView==_guideListTableView )
        return 60;
    else if (tableView==_chengSeTableView)
        return 55;
    else if (tableView==_searchMemberTableView)
        return 90;
    else
    return 50;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
     if (tableView==_shopCartTableView) {
    static NSString * identifier = @"Cell";
    ShopCartTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    
    if (cell==nil) {
        NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"ShopCartTableViewCell" owner:self options:nil];
        cell = [array objectAtIndex:0];
        cell.delegate=self;
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.priceDetailBtn.tag=indexPath.row;
    if (shopCartWeightArray.count>0) {
        cell.weightLabel.text=[NSString stringWithFormat:@"%0.02fg",[[shopCartWeightArray objectAtIndex:indexPath.row] floatValue]];
        //[self resizeLabel:cell.weightLabel];
       // cell.weightLabel.text=[shopCartDocTypeArray objectAtIndex:indexPath.row];
        cell.weightLabel.numberOfLines = 0;
        cell.weightLabel.lineBreakMode = NSLineBreakByWordWrapping;
        CGSize maximumLabelSize = CGSizeMake(1000, cell.weightLabel.frame.size.height);
        
        CGSize expectSize = [cell.weightLabel sizeThatFits:maximumLabelSize];
        CGRect frame1 = CGRectMake(cell.weightLabel.frame.origin.x, cell.weightLabel.frame.origin.y,expectSize.width, cell.weightLabel.frame.size.height );
        cell.weightLabel.frame=frame1;

    }
    if (shopCartAddressArray.count>0) {
        cell.addressLabel.text=[shopCartAddressArray objectAtIndex:indexPath.row];
    }
    if (shopCartAttributeArray.count>0) {
        if ([shopCartAttributeArray objectAtIndex:indexPath.row]!=[NSNull null]) {
                 cell.attributesLabel.text=[NSString stringWithFormat:@"%@",[shopCartAttributeArray objectAtIndex:indexPath.row]];
                 
            }
             cell.attributesLabel.numberOfLines = 0;
             cell.attributesLabel.lineBreakMode = NSLineBreakByWordWrapping;
             CGSize maximumLabelSize = CGSizeMake(1000, cell.attributesLabel.frame.size.height);
             
             CGSize expectSize = [cell.attributesLabel sizeThatFits:maximumLabelSize];
             CGRect frame1 = CGRectMake(cell.attributesLabel.frame.origin.x, cell.attributesLabel.frame.origin.y,expectSize.width, cell.attributesLabel.frame.size.height );
             cell.attributesLabel.frame=frame1;

            // [self resizeLabel: cell.attributesLabel];
             
             CGRect frame= cell.weightTagLabel.frame;
             if ([[shopCartAttributeArray objectAtIndex:indexPath.row] length]>0) {
                 
                 frame.origin.x=cell.attributesLabel.frame.origin.x+cell.attributesLabel.frame.size.width+12;
             }
             else
             {
                 frame.origin.x=cell.attributesLabel.frame.origin.x+cell.attributesLabel.frame.size.width;
             }
             cell.weightTagLabel.frame=frame;
             
             CGRect frame2= cell.weightLabel.frame;
             frame2.origin.x=cell.weightTagLabel.frame.origin.x+cell.weightTagLabel.frame.size.width+1;
             cell.weightLabel.frame=frame2;
             
         }

    if (shopCartNameArray.count>0) {
        cell.nameLabel.text=[NSString stringWithFormat:@"%@  %@",[shopCartCodeArray objectAtIndex:indexPath.row ],[shopCartNameArray objectAtIndex:indexPath.row]];
    }
    if (shopCartDocTypeArray.count>0) {
//       if([[shopCartDocTypeArray objectAtIndex:indexPath.row] length]>0)
//       {
        cell.docTypeLabel.text=[shopCartDocTypeArray objectAtIndex:indexPath.row];
        cell.docTypeLabel.numberOfLines = 0;
        cell.docTypeLabel.lineBreakMode = NSLineBreakByWordWrapping;
        CGSize maximumLabelSize = CGSizeMake(1000, cell.docTypeLabel.frame.size.height);
        
        CGSize expectSize = [cell.docTypeLabel sizeThatFits:maximumLabelSize];
        CGRect frame1 = CGRectMake(cell.docTypeLabel.frame.origin.x, cell.docTypeLabel.frame.origin.y,expectSize.width, cell.docTypeLabel.frame.size.height );
        cell.docTypeLabel.frame=frame1;
        CGRect frame=cell.nameLabel.frame;
        frame.origin.x=cell.docTypeLabel.frame.origin.x+cell.docTypeLabel.frame.size.width+2;
        cell.nameLabel.frame=frame;
        
         }

    if (shopCartMarketArray.count>0) {
         if ([shopCartMarketArray objectAtIndex:indexPath.row]!=[NSNull null]) {
        float AvgPrice=[[shopCartMarketArray objectAtIndex:indexPath.row] floatValue];
        NSString *AvgPriceStr=[Global floatConvertPercentile:AvgPrice];
       // NSString *marketStr=[NSString stringWithFormat:@"¥%0.02f",[[shopCartMarketArray objectAtIndex:indexPath.row] floatValue]];
             cell.marketPriceLabel.text=[NSString stringWithFormat:@"¥%@",AvgPriceStr];//[shopCartMarketArray objectAtIndex:indexPath.row];
             
             CGRect frame1= cell.marketPriceTagLabel.frame;
             frame1.origin.x=cell.weightLabel.frame.origin.x+cell.weightLabel.frame.size.width+10;
             cell.marketPriceTagLabel.frame=frame1;
             
             CGRect frame2= cell.marketPriceLabel.frame;
             frame2.origin.x=cell.marketPriceTagLabel.frame.origin.x+cell.marketPriceTagLabel.frame.size.width+3;
             cell.marketPriceLabel.frame=frame2;

             
    }
    }
    
    if (shopCartSaleArray.count>0) {
        if ([shopCartSaleArray objectAtIndex:indexPath.row]!=[NSNull null]) {
            
            float AvgPrice=[[shopCartSaleArray objectAtIndex:indexPath.row] floatValue];
            NSString *AvgPriceStr=[Global floatConvertPercentile:AvgPrice];
      //  NSString *saleStr=[NSString stringWithFormat:@"%0.02f",[[shopCartSaleArray objectAtIndex:indexPath.row] floatValue]];
        cell.salePriceLabel.text=AvgPriceStr;
        }//[shopCartSaleArray objectAtIndex:indexPath.row];
    }
    if (shopCartImageArray.count>0) {
         NSString *urlStr=[shopCartImageArray objectAtIndex:indexPath.row];
        if (urlStr.length>0) {
        
         [cell.prouctImageView setImageWithURL:[NSURL URLWithString:urlStr]];
        }
        else
        {
        [cell.prouctImageView setImage:[UIImage imageNamed:@"zhanweitu_.png"]];
        }
    }
    
       if (indexPath.row == [shopCartImageArray count] - 1 )
    {
        if (_productPageIndex<=_productTotalPage) {
        //    NSLog(@"###LOADING???");
            [self loadProductNextPage:_productPageIndex];
        }

    }
    return cell;
     }
    else if (tableView==_cashierListTableView)
    {
        static NSString * const  GuideListIdentifier = @"GuideListCellIdentifier";
        CommonDetailTableViewCell *cell=( CommonDetailTableViewCell *)[tableView dequeueReusableCellWithIdentifier: GuideListIdentifier];
        if (cell==nil) {
            NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"CommonDetailTableViewCell" owner:self options:nil];
            cell = [array objectAtIndex:0];
        }
        if (shopCartWeightArray.count>0) {
            cell.weightLabel.text=[NSString stringWithFormat:@"%0.02fg",[[shopCartWeightArray objectAtIndex:indexPath.row] floatValue]];
            //[self resizeLabel:cell.weightLabel];
            // cell.weightLabel.text=[shopCartDocTypeArray objectAtIndex:indexPath.row];
            cell.weightLabel.numberOfLines = 0;
            cell.weightLabel.lineBreakMode = NSLineBreakByWordWrapping;
            CGSize maximumLabelSize = CGSizeMake(1000, cell.weightLabel.frame.size.height);
            
            CGSize expectSize = [cell.weightLabel sizeThatFits:maximumLabelSize];
            CGRect frame1 = CGRectMake(cell.weightLabel.frame.origin.x, cell.weightLabel.frame.origin.y,expectSize.width, cell.weightLabel.frame.size.height );
            cell.weightLabel.frame=frame1;
            
        }

        if (shopCartSaleArray.count>0) {
            if ([shopCartSaleArray objectAtIndex:indexPath.row]!=[NSNull null]) {
                float AvgPrice=[[shopCartSaleArray objectAtIndex:indexPath.row] floatValue];
                NSString *AvgPriceStr=[Global floatConvertPercentile:AvgPrice];
                // NSString *marketStr=[NSString stringWithFormat:@"¥%0.02f",[[shopCartMarketArray objectAtIndex:indexPath.row] floatValue]];
                cell.priceLabel.text=[NSString stringWithFormat:@"¥%@",AvgPriceStr];//[shopCartMarketArray objectAtIndex:indexPath.row];
                
                CGRect frame1= cell.priceLabel.frame;
                frame1.origin.x=cell.weightLabel.frame.origin.x+cell.weightLabel.frame.size.width+10;
                cell.priceLabel.frame=frame1;
            
                
                
            }
        }

        if (shopCartNameArray.count>0) {
            cell.productNameLabel.text=[NSString stringWithFormat:@"%@  %@",[shopCartCodeArray objectAtIndex:indexPath.row ],[shopCartNameArray objectAtIndex:indexPath.row]];
        }
        if (shopCartAddressArray.count>0) {
                cell.stockAddressLabel.text=[shopCartAddressArray objectAtIndex:indexPath.row];
            }

        if (shopCartImageArray.count>0) {
            NSString *urlStr=[shopCartImageArray objectAtIndex:indexPath.row];
            if (urlStr.length>0) {
                
                [cell.productImageView setImageWithURL:[NSURL URLWithString:urlStr]];
            }
            else
            {
                [cell.productImageView setImage:[UIImage imageNamed:@"zhanweitu_.png"]];
            }
        }

        return cell;
        
    }
     else if (tableView==_guideListTableView )
     {
         static NSString * const  GuideListIdentifier = @"GuideListCellIdentifier";
         GuideListTableViewCell *cell=( GuideListTableViewCell *)[tableView dequeueReusableCellWithIdentifier: GuideListIdentifier];
         if (cell==nil) {
             NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"GuideListTableViewCell" owner:self options:nil];
             cell = [array objectAtIndex:0];
         }
         
         if (guideNameArray.count>0) {
             cell.guideNameLabel.text=[guideNameArray objectAtIndex:indexPath.row];
         }
         return cell;
         
     }
    else if (tableView==_chengSeTableView)
    {
        static NSString * const  chengSeIdentifier = @"chengSeIdentifier";
        GuideListTableViewCell *cell=( GuideListTableViewCell *)[tableView dequeueReusableCellWithIdentifier: chengSeIdentifier];
        if (cell==nil) {
            NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"GuideListTableViewCell" owner:self options:nil];
            cell = [array objectAtIndex:0];
        }
        
        if (chengSeNameArray.count>0) {
            cell.guideNameLabel.text=[chengSeNameArray objectAtIndex:indexPath.row];
//            UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 54,600, 2)];
//            lineLabel.text=@"－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－";
//            lineLabel.textColor=[UIColor colorWithRed:240.0f/255.0f green:240.0f/255.0f blue:240.0f/255.0f alpha:1.0f];
//            [cell.contentView addSubview:lineLabel];
        }
        return cell;

    }
    else  if (tableView==_searchMemberTableView) {
        
        
        static NSString * const  MemberListIdentifier = @"MemberListCellIdentifier";
        SearchMemberTableViewCell *cell=( SearchMemberTableViewCell *)[tableView dequeueReusableCellWithIdentifier: MemberListIdentifier];
        if (cell==nil) {
            NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"SearchMemberTableViewCell" owner:self options:nil];
            cell = [array objectAtIndex:0];
        }
         cell.selectionStyle = UITableViewCellSelectionStyleNone;
        if (memberSexArray.count>0) {
            if ([[memberSexArray objectAtIndex:indexPath.row] isEqualToString:@"男"]) {
                [cell.sexImageView setImage:[UIImage imageNamed:@"nan_.png"]];
            }
            else
                [cell.sexImageView setImage:[UIImage imageNamed:@"nv_.png"]];
        }
        
        if (memberGradeArray.count>0) {
            cell.gradeLabel.text=[memberGradeArray objectAtIndex:indexPath.row];
            cell.gradeLabel.numberOfLines = 0;
            cell.gradeLabel.lineBreakMode = NSLineBreakByWordWrapping;
            CGSize maximumLabelSize = CGSizeMake(1000, cell.gradeLabel.frame.size.height);
            
            CGSize expectSize = [cell.gradeLabel sizeThatFits:maximumLabelSize];
            CGRect frame0 = CGRectMake(cell.gradeLabel.frame.origin.x, cell.gradeLabel.frame.origin.y,expectSize.width, cell.gradeLabel.frame.size.height );
            cell.gradeLabel.frame=frame0;

        }

        if (memberPhoneArray.count>0&&memberNameArray.count>0) {
            NSString *phoneStr=[memberPhoneArray objectAtIndex:indexPath.row];
            NSString *nameStr=[memberNameArray objectAtIndex:indexPath.row];
            NSString *str1=@"(";
            NSString *str2=@")";
            cell.nameAndPhoneLabel.text=[NSString stringWithFormat:@"%@%@%@%@",nameStr,str1,phoneStr,str2];
           // [self resizeLabel:cell.nameAndPhoneLabel];
             [Global resizeForLable:cell.nameAndPhoneLabel WithText:cell.nameAndPhoneLabel.text parentView:self.view];
            
            //            NSLog(@"phoneStr====%@",phoneStr);
            //            NSLog(@"nameStr====%@",nameStr);
            //            NSLog(@" cell.nameAndPhoneLabel.text====%@", cell.nameAndPhoneLabel.text);
            
            CGRect frame=cell.sexImageView.frame;
            frame.origin.x=cell.nameAndPhoneLabel.frame.origin.x+cell.nameAndPhoneLabel.frame.size.width;
            cell.sexImageView.frame=frame;
            
            CGRect frame1=cell.gradeTagLabel.frame;
            frame1.origin.x=cell.sexImageView.frame.origin.x+cell.sexImageView.frame.size.width+11;
            cell.gradeTagLabel.frame=frame1;
            
            CGRect frame2=cell.gradeLabel.frame;
            frame2.origin.x=cell.gradeTagLabel.frame.origin.x+cell.gradeTagLabel.frame.size.width+2;
            cell.gradeLabel.frame=frame2;
            
            CGRect frame3=cell.integralTagLabel.frame;
            frame3.origin.x=cell.gradeLabel.frame.origin.x+cell.gradeLabel.frame.size.width+11;
            cell.integralTagLabel.frame=frame3;
            
            CGRect frame4=cell.integralLabel.frame;
            frame4.origin.x=cell.integralTagLabel.frame.origin.x+cell.integralTagLabel.frame.size.width+2;
            cell.integralLabel.frame=frame4;
        }
        if (memberAddressArray.count>0) {
            NSString *addressStr1=[memberAddressArray objectAtIndex:indexPath.row];
            if (addressStr1.length>0) {
                cell.addressLabel.text=addressStr1;
            }
            else
            {
                cell.addressLabel.text=@"未填写";
            }
        }
        if (memberIntegralArray.count>0) {
            cell.integralLabel.text=[NSString stringWithFormat:@"%ld",(long)[[memberIntegralArray objectAtIndex:indexPath.row] integerValue]];
        }
        if (indexPath.row == [memberCodeArray count] - 1)
        {
            if (_memberPageIndex<=_memberTotalPage) {
                //  NSLog(@"###LOADING???");
                [self loadMemberNextPage:_memberPageIndex];
            }
        }
        return cell;
    }

   else
   {
       static NSString * const  OldMeterialIdentifier = @"OldMeterialIdentifier";
       OldMeterialTableViewCell *cell=( OldMeterialTableViewCell *)[tableView dequeueReusableCellWithIdentifier: OldMeterialIdentifier];
       if (cell==nil) {
           NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"OldMeterialTableViewCell" owner:self options:nil];
           cell = [array objectAtIndex:0];
       }
       cell.delegate=self;
       cell.lineLabel.hidden=YES;
       cell.dotLineLabel.hidden=NO;
      
       cell.inputTextField.tag=indexPath.row;
       if (oldChengSeArray.count>0) {
           cell.chengSeLabel.text=[oldChengSeArray objectAtIndex:indexPath.row];
       }
       if (oldRecyclePriceArray.count>0) {
           float AvgPrice=[[oldRecyclePriceArray objectAtIndex:indexPath.row ] floatValue];
           NSString *AvgPriceStr=[Global floatConvertPercentile:AvgPrice];

           cell.recyclePriceLabel.text=AvgPriceStr;
       }
       if (oldLossArray.count>0) {
           cell.lossLabel.text=[NSString stringWithFormat:@"%@%%",[oldLossArray objectAtIndex:indexPath.row]];
       }
       if (oldWeightArray.count>0) {
           cell.weightLabel.text=[oldWeightArray objectAtIndex:indexPath.row];
       }
       if (oldPriceArray.count>0) {
           float AvgPrice=[[oldPriceArray objectAtIndex:indexPath.row ] floatValue];
           NSString *AvgPriceStr=[Global floatConvertPercentile:AvgPrice];

           cell.priceLabel.text=[NSString stringWithFormat:@"%@",AvgPriceStr];
           cell.inputTextField.text=[NSString stringWithFormat:@"%@",AvgPriceStr];
       }
       if (oldRealPriceArray.count>0) {
           float AvgPrice=[[oldRealPriceArray objectAtIndex:indexPath.row ] floatValue];
           NSString *AvgPriceStr=[Global floatConvertPercentile:AvgPrice];
           
         
           cell.inputTextField.text=[NSString stringWithFormat:@"%@",AvgPriceStr];
       }

       if (indexPath.row==oldPriceArray.count-1) {
           cell.lineLabel.hidden=NO;
           cell.dotLineLabel.hidden=YES;
       }
       return cell;

   }

}
-(void)textfieldBeginEdit
{
    [UIView animateWithDuration:0.3 animations:^{
        CGRect viewFrame=_oldMeterialScrollView.frame;
        viewFrame.origin.y=-(_oldMeterialTableview.frame.origin.y+_oldMeterialTableview.frame.size.height-_oldMeterialScrollView.contentOffset.y+350-768);
        _oldMeterialScrollView.frame=viewFrame;
    } completion:^(BOOL finished){
    }];
 

}
-(void)textFieldFinish:(UITextField *)textfield
{
    [_oldMeterialScrollView setContentOffset:CGPointMake(0, 0)];
    [UIView animateWithDuration:0.5 animations:^{
        
        
        CGRect frame=_oldMeterialScrollView.frame;
        
        frame.origin.y=0;
        [_oldMeterialScrollView setFrame:frame];
        
    } completion:^(BOOL finished){
        
    }];

    [oldRealPriceArray replaceObjectAtIndex:textfield.tag withObject:textfield.text];
    float total=0.0f;
    for (int i=0;i<oldRealPriceArray.count; i++) {
        total=total+[[oldRealPriceArray objectAtIndex:i] floatValue];
    }
    oldMeterialTotalAmountFloat=total;
    NSString *AvgPriceStr=[Global floatConvertPercentile:oldMeterialTotalAmountFloat];
    _oldMeterialTotalAmountLabel.text=AvgPriceStr;

    
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
     if (tableView==_shopCartTableView||tableView==_oldMeterialTableview) {
    return YES;
     }
    return NO;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
     if (tableView==_shopCartTableView)
     {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        if ([Global getLoginToken].length>0) {
            [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
            NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
            
//            UITableViewCell *cell = [_shopCartTableView cellForRowAtIndexPath:indexPath];
//            ShopCartTableViewCell *shopCartCell=( ShopCartTableViewCell *)cell
            [params setObject:[Global getLoginToken] forKey:@"Token"];
            NSString *codeStr=[shopCartCodeArray objectAtIndex:indexPath.row];
            [params setObject:codeStr forKey:@"ItemCode"];
            [params setObject:@"D" forKey:@"EditType"];
            //  NSNumber *Number = [NSNumber numberWithInteger: [_countLabel.text integerValue]];
          //  [params setObject:shopCartCell.countLabel.text forKey:@"Quantity"];
           // NSLog(@"paramsDELETE===%@",params);
            [HttpRequest requestData:@"Guide/EditShopCart" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
                if (isSuccess) {
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                        [Global hideProgressHUDInternal:self.view];
                      //  NSLog(@"DeleteShopCart===%@", [severDataDict.dataDict objectForKey:@"ResultString"] );
                       
                        [shopCartAllArray removeObjectAtIndex:indexPath.row];
                        [shopCartImageArray removeObjectAtIndex:indexPath.row];
                        [shopCartNameArray removeObjectAtIndex:indexPath.row];
                        [shopCartDocTypeArray removeObjectAtIndex:indexPath.row];
                        [shopCartAddressArray removeObjectAtIndex:indexPath.row];
                        [shopCartAttributeArray removeObjectAtIndex:indexPath.row];
                        [shopCartWeightArray removeObjectAtIndex:indexPath.row];
                        [shopCartSaleArray removeObjectAtIndex:indexPath.row];
                        [shopCartMarketArray removeObjectAtIndex:indexPath.row];
//                        if ([selectedCodeArray containsObject:[shopCartCodeArray objectAtIndex:indexPath.row]]) {
//                            NSInteger index=[selectedCodeArray indexOfObject:[shopCartCodeArray objectAtIndex:indexPath.row]];
//                           
//                            [selectedCountArray removeObjectAtIndex:index];
//
//                            [selectedCodeArray removeObject:[shopCartCodeArray objectAtIndex:indexPath.row]];
//                        }
                        [shopCartCodeArray removeObjectAtIndex:indexPath.row];
                        //        // Delete the row from the data source.
                       // [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
                        // [tableView deleteRowsAtIndexPaths:indexPath withRowAnimation:UITableViewRowAnimationFade];
                       // [tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];
                     //   [tableView reloadData];
                          _shopCartTotalLabel.text=[NSString stringWithFormat:@"购物车共有%lu件产品",(unsigned long)shopCartCodeArray.count];
                        float total=0.0;
                   //     NSLog(@"shopCartSaleArray========%@",shopCartSaleArray);
                        for (int i=0; i<shopCartSaleArray.count; i++) {
                            if ([shopCartSaleArray objectAtIndex:i]!=[NSNull null]) {
                                total=total+[[shopCartSaleArray objectAtIndex:i] floatValue];
                             //    NSLog(@"total111========%f",total);
                            }
                            
                        }
                       // float AvgPrice=[[allcatePriceArray objectAtIndex:indexPath.row] floatValue];
                        
                      //   NSLog(@"total========%f",total);
                        NSString *AvgPriceStr=[Global floatConvertPercentile:total];
                        _totalResultLabel.text=[NSString stringWithFormat:@"¥%@",AvgPriceStr];
                        
                        // NSLog(@"AvgPriceStr========%@",AvgPriceStr);
//                         [tableView beginUpdates];
//                        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]  withRowAnimation:UITableViewRowAnimationFade];
//                        [tableView endUpdates];
                      //  [tableView reloadData];
                        
                         [_shopCartTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
                        [tableView reloadData];
                       //  NSLog(@"shopCartMarketArray11111==%@",shopCartMarketArray);

                    }
                    else
                    {
                         [Global hideProgressHUDInternal:self.view];
                        NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                        //  [Global showTextHud:requestResultStr view:self.view];
                        [Global showTextHudSub:requestResultStr view:self.view];
                        
                        if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                            
                            if (_timer!=nil) {
                                [_timer invalidate];
                                _timer=nil;
                            }
                         [Global loginViewController:self noteStr:requestResultStr];
                         //   [Global loginViewController:self];
                        }
                    }
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    [Global showTextHudSub:@"连接失败" view:self.view];
                }
            }];
            
        }
    }
    }
     else if (tableView==_oldMeterialTableview)
     {
         [oldLossArray removeObjectAtIndex:indexPath.row];
         [oldChengSeArray removeObjectAtIndex:indexPath.row];
         [oldChengSeCodeArray removeObjectAtIndex:indexPath.row];
         [oldWeightArray removeObjectAtIndex:indexPath.row];
         [oldRecyclePriceArray removeObjectAtIndex:indexPath.row];
         [oldPriceArray removeObjectAtIndex:indexPath.row];
         [oldRealPriceArray removeObjectAtIndex:indexPath.row];
//         [_oldMeterialTableview reloadData];
           [_oldMeterialTableview deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
         float total=0.0f;
         for (int i=0;i<oldRealPriceArray.count; i++) {
             total=total+[[oldRealPriceArray objectAtIndex:i] floatValue];
         }
         oldMeterialTotalAmountFloat=total;
         NSString *AvgPriceStr=[Global floatConvertPercentile:oldMeterialTotalAmountFloat];
         _oldMeterialTotalAmountLabel.text=AvgPriceStr;
         
     }

   }
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{
    return @"删除";
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (tableView==_guideListTableView) {
        guideCodeStr=[guideCodeArray objectAtIndex:indexPath.row];
        
        _guideListViewContainer.hidden=YES;
        [UIView animateWithDuration:0.5 animations:^{
            
            UIImage *closeImage=[UIImage imageNamed:@"jiantou_down.png"];
            [_guideListArrowImage setImage:closeImage];
            CGRect frame=_guideListViewContainer.frame;
            
            frame.size.height=1;
            [_guideListViewContainer setFrame:frame];
            
        } completion:^(BOOL finished){
            isOpened=NO;
        }];
        _guideNameLabel.text=[guideNameArray objectAtIndex:indexPath.row];
        [Global resizeForLable:_guideNameLabel WithText:_guideNameLabel.text parentView:self.view];
        CGRect frameK=_guideNameLabel.frame;
        frameK.origin.x=_guideListArrowImage.frame.origin.x-frameK.size.width-5;
        _guideNameLabel.frame=frameK;
    }
  else if (tableView==_chengSeTableView)
  {
      _chengSeTextField.text=[chengSeNameArray objectAtIndex:indexPath.row];
      _chengSeViewContainer.hidden=YES;
      [UIView animateWithDuration:0.5 animations:^{
          
          UIImage *closeImage=[UIImage imageNamed:@"jiantou_down.png"];
          [_chengSeListArrow setImage:closeImage];
          CGRect frame=_chengSeViewContainer.frame;
          
          frame.size.height=1;
          [_chengSeViewContainer setFrame:frame];
          
      } completion:^(BOOL finished){
          chengSeListIsOpen=NO;
      }];

  }
    else if (tableView==_searchMemberTableView)
  {
       _decutibleLabel.text=@"";
      _depositText.text=@"";
      _integralTextField.text=@"";
      _deductibleTextField.text=@"";
      _oldMeterialTextField.text=@"";
       _cashierLastTotalLabel.text=_cashierTotalLabel.text;
      selectDepositCellTagStr=@"";
      CGRect frame0=_searchMemberViewContainer.frame;
      
      frame0.origin.y=768;
      [_searchMemberViewContainer setFrame:frame0];
      
      NSString *nameStr=[memberNameArray objectAtIndex:indexPath.row];
      NSString *phoneStr=[memberPhoneArray objectAtIndex:indexPath.row];
      memberCodeStr=[memberCodeArray objectAtIndex:indexPath.row];
      //  NSString *integralStr=[memberIntegralArray objectAtIndex:indexPath.row];
      _memberAndPhoneLabel.text=[NSString stringWithFormat:@"%@(%@)",nameStr,phoneStr];
      
    //  [self resizeLabel:_memberAndPhoneLabel];
       [Global resizeForLable:_memberAndPhoneLabel WithText:_memberAndPhoneLabel.text parentView:self.view];
      
      integralAvailabalStr=[NSString stringWithFormat:@"%0.02f",[[memberIntegralAmountArray objectAtIndex:indexPath.row] floatValue]];
      _integralAvailabelLabel.text=[NSString stringWithFormat:@"可抵  ¥%@",integralAvailabalStr];
//      if ([memberGradeArray objectAtIndex:indexPath.row]!= [NSNull null])
//      {
          NSString *gradeStr=[memberGradeArray objectAtIndex:indexPath.row];
          _memberGradeLabel.text=gradeStr;
          _memberGradeTagLabel.hidden=NO;
          _memberGradeLabel.hidden=NO;
          _memberIntegralLabel.hidden=NO;
          _memberIntegralTagLabel.hidden=NO;
        //  [self resizeLabel:_memberGradeLabel];
         [Global resizeForLable:_memberGradeLabel WithText:_memberGradeLabel.text parentView:self.view];
          //_memberGradeLabel.text=[severDataDict.dataDict objectForKey:@"Grade"];
      //}
     // if (memberIntegralArray.count>0) {
          NSString *integralStr=[NSString stringWithFormat:@"%d",[[memberIntegralArray objectAtIndex:indexPath.row] integerValue]];
          _memberIntegralLabel.text=integralStr;
     // }

//      CGRect frame=_memberSexImage.frame;
//      frame.origin.x=_memberAndPhoneLabel.frame.origin.x+_memberAndPhoneLabel.frame.size.width+2;
//      _memberSexImage.frame=frame;
      
      CGRect frame1=_memberGradeTagLabel.frame;
      frame1.origin.x=_memberAndPhoneLabel.frame.origin.x+_memberAndPhoneLabel.frame.size.width+12;
      _memberGradeTagLabel.frame=frame1;
      
      CGRect frame2=_memberGradeLabel.frame;
      frame2.origin.x=_memberGradeTagLabel.frame.origin.x+_memberGradeTagLabel.frame.size.width+2;
      _memberGradeLabel.frame=frame2;
      
      CGRect frame3=_memberIntegralTagLabel.frame;
      frame3.origin.x=_memberGradeLabel.frame.origin.x+_memberGradeLabel.frame.size.width+12;
      _memberIntegralTagLabel.frame=frame3;
      
      CGRect frame4=_memberIntegralLabel.frame;
      frame4.origin.x=_memberIntegralTagLabel.frame.origin.x+_memberIntegralTagLabel.frame.size.width+2;
      _memberIntegralLabel.frame=frame4;
      
      
  }

   // ShopCartTableViewCell *cell = (ShopCartTableViewCell*)[tableView cellForRowAtIndexPath:indexPath];
    
         // _totalResultLabel.text=[NSString stringWithFormat:@"%d",totalResultValue];
}
-(void)priceDetailClick:(NSUInteger)tag
{
    priceDetailCellTag=tag;
   // NSLog(@"tag==%d",tag);
   // NSLog(@"shopCartMarketArray==%@",shopCartMarketArray);
    if ([[shopCartMarketArray objectAtIndex:tag] floatValue]>0) {
        _marketPriceLabel.text=[Global floatConvertPercentile:[[shopCartMarketArray objectAtIndex:tag] floatValue]];
        priceDetail1DiscountValueFloat=[[shopCartSaleArray objectAtIndex:tag] floatValue];
        _priceDetailtotalValueLabel1.text=[Global floatConvertPercentile:priceDetail1DiscountValueFloat];//[NSString stringWithFormat:@"%0.02f",[[shopCartSaleArray objectAtIndex:tag] floatValue]];
        CGRect frame=_priceDetailViewContainer.frame;
        
        frame.origin.y=768;
        [_priceDetailViewContainer setFrame:frame];
        
        [UIView animateWithDuration:0.5 animations:^{
            
            CGRect frame=_priceDetailViewContainer1.frame;
            
            frame.origin.y=0;
            [_priceDetailViewContainer1 setFrame:frame];
            
        } completion:^(BOOL finished){
            
        }];
        

    }
    else
    {
        CGRect frame=_priceDetailViewContainer1.frame;
        
        frame.origin.y=768;
        [_priceDetailViewContainer1 setFrame:frame];
        [UIView animateWithDuration:0.5 animations:^{
            
            CGRect frame=_priceDetailViewContainer.frame;
            
            frame.origin.y=0;
            [_priceDetailViewContainer setFrame:frame];
            
        } completion:^(BOOL finished){
            
        }];
        

    }
    [self requestPriceDetail:[shopCartCodeArray objectAtIndex:tag]];
}
-(void)requestPriceDetail:(NSString *)codeStr
{
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
         [params setObject:codeStr forKey:@"ItemCode"];
        [HttpRequest requestData:@"Guide/PriceDetail" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            // NSLog(@"serrr==%@",severDataDict.dataDict);
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    if ([[shopCartMarketArray objectAtIndex:priceDetailCellTag] floatValue]>0) {
                        
                        if ([[severDataDict.dataDict objectForKey:@"DisAmount"] floatValue]>0) {
                            _discountTextField1.text=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"DisAmount"] floatValue]];
                            _discountLabel1.text=[NSString stringWithFormat:@"-¥%0.02f",[_discountTextField1.text floatValue]];
                            _discountRateTextField.text=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"DisRate"] floatValue]];
                            
                          //  NSLog(@"rwrwrw====%0.02f",[[severDataDict.dataDict objectForKey:@"DisRate"] floatValue]);
                            
                        }
                        else
                        {
                            _discountTextField1.text=@"";
                            _discountRateTextField.text=@"";
                            _discountLabel1.text=@"";
                            
                        }
                            
                    _priceDetailtotalValueLabel1.text=[Global floatConvertPercentile:[[shopCartMarketArray objectAtIndex:priceDetailCellTag] floatValue]-[_discountTextField1.text floatValue]];
                            
                        

                    }
                    else
                    {
                        weightStr=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"Gram"] floatValue]];
                        _weightLabel1.text=weightStr;
                        _weightLabel2.text= _weightLabel1.text;
                        todayGoldPriceStr=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"GoldPrice"] floatValue]];
                        _todayGoldPriceTextField.text=todayGoldPriceStr;
                        
                        processPriceStr=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"ProcessPrice"] floatValue]];
                        _processPriceTextField.text=processPriceStr;
                        
                        cutGoldStr=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"CutQty"] floatValue]];
                        if ([[severDataDict.dataDict objectForKey:@"CutQty"] floatValue]>0) {
                            _cutGoldTextField.text=cutGoldStr;
                            
                        }
                        else
                        {
                            _cutGoldTextField.text=@"";
                        }
                        if ([[severDataDict.dataDict objectForKey:@"DisAmount"] floatValue]>0) {
                            _discountTextField.text=[NSString stringWithFormat:@"%0.02f",[[severDataDict.dataDict objectForKey:@"DisAmount"] floatValue]];
                            
                        }
                        else
                        {
                            _discountTextField.text=@"";
                        }
                        
                        
                        
                        _goldPriceTextField.text=[NSString stringWithFormat:@"%0.02f",[weightStr floatValue]*[todayGoldPriceStr floatValue]];
                        _processFeeTextField.text=[NSString stringWithFormat:@"%0.02f",[weightStr floatValue]*[processPriceStr floatValue]];
                        _cutGoldLabel.text=[NSString stringWithFormat:@"-¥%0.02f",[cutGoldStr floatValue]*([todayGoldPriceStr floatValue]+[_processPriceTextField.text floatValue])];
                        _discountLabel.text=[NSString stringWithFormat:@"-¥%0.02f",[_discountTextField.text floatValue]];
                        
                      //  NSString *remarkStr=[severDataDict.dataDict objectForKey:@"Remark"];
//                        if (remarkStr.length>0) {
//                            _remarkTextView.text=remarkStr;
//                            _textviewImage.hidden=YES;
//                            _textviewLabel.hidden=YES;
//                            
//                        }
//                        else
//                        {
//                            _remarkTextView.text=@"";
//                            _textviewImage.hidden=NO;
//                            _textviewLabel.hidden=NO;
//                        }
                        
                        priceDetailDiscountValueFloat=[_goldPriceTextField.text floatValue]+[_processFeeTextField.text floatValue]-[cutGoldStr floatValue]*([todayGoldPriceStr floatValue]+[_processPriceTextField.text floatValue])-[_discountTextField.text floatValue];
                       //   _priceDetailtotalValueLabel.text=[Global floatConvertPercentile:[_goldPriceTextField.text floatValue]+[_processFeeTextField.text floatValue]-[cutGoldStr floatValue]*([todayGoldPriceStr floatValue]+[_processPriceTextField.text floatValue])-[_discountTextField.text floatValue]];
                        _priceDetailtotalValueLabel.text=[Global floatConvertPercentile:priceDetailDiscountValueFloat];
                    }

                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                        
                        if (_timer!=nil) {
                            [_timer invalidate];
                            _timer=nil;
                        }
                     [Global loginViewController:self noteStr:requestResultStr];
                      //  [Global loginViewController:self];
                    }

                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
        
    }

}
-(IBAction)priceDetailConfirmClick:(id)sender
{
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        [params setObject:_todayGoldPriceTextField.text forKey:@"GoldPrice"];
        [params setObject:_goldPriceTextField.text forKey:@"GoldAmount"];
       
        [params setObject:_processPriceTextField.text forKey:@"ProcessPrice"];
        [params setObject:_processFeeTextField.text forKey:@"ProcessAmount"];
        [params setObject:_cutGoldTextField.text forKey:@"CutQty"];
        [params setObject:_discountTextField.text forKey:@"DisAmount"];
       // [params setObject:_remarkTextView.text forKey:@"Remark"];
        [params setObject:[shopCartCodeArray objectAtIndex:priceDetailCellTag] forKey:@"ItemCode"];
       // NSLog(@"ccccc===%@",params);
        [HttpRequest requestData:@"Guide/EditPriceDetail" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            //  NSLog(@"serrr==%@",severDataDict.dataDict);
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    [UIView animateWithDuration:0.5 animations:^{
                        
                        CGRect frame=_priceDetailViewContainer.frame;
                        
                        frame.origin.y=768;
                        [_priceDetailViewContainer setFrame:frame];
                        
                    } completion:^(BOOL finished){
                        
                    }];
                    NSString *discountStr=[NSString stringWithFormat:@"%0.02f",priceDetailDiscountValueFloat];
                    [shopCartSaleArray replaceObjectAtIndex:priceDetailCellTag withObject:discountStr];
                    NSIndexPath *indexPath1= [NSIndexPath indexPathForRow:priceDetailCellTag inSection:0];
                    UITableViewCell *cell = [_shopCartTableView cellForRowAtIndexPath:indexPath1];
                    ShopCartTableViewCell *shopCartCell=( ShopCartTableViewCell *)cell;
                    shopCartCell.salePriceLabel.text=_priceDetailtotalValueLabel.text;
                    
                    float value=0.00f;
                    for (int i=0; i<shopCartCodeArray.count; i++) {
//                        NSIndexPath *indexPath1= [NSIndexPath indexPathForRow:i inSection:0];
//                        UITableViewCell *cell = [_shopCartTableView cellForRowAtIndexPath:indexPath1];
//                        ShopCartTableViewCell *shopCartCell=( ShopCartTableViewCell *)cell;
//                        value=value+  [shopCartCell.salePriceLabel.text floatValue];
                        value=value+[[shopCartSaleArray objectAtIndex:i] floatValue];

                    }
                    _totalResultLabel.text=[NSString stringWithFormat:@"%0.02f",value];
                    _weightLabel1.text=@"";
                    _weightLabel2.text= @"";
                    todayGoldPriceStr=@"";
                    _todayGoldPriceTextField.text=@"";
                    
                    processPriceStr=@"";
                    _processPriceTextField.text=@"";
                    
                    cutGoldStr=@"";
                    _cutGoldTextField.text=@"";
                    _discountTextField.text=@"";
                    _goldPriceTextField.text=@"";
                    _processFeeTextField.text=@"";
                    _cutGoldLabel.text=@"";
                    _discountLabel.text=@"";
                    
                   
//                    _remarkTextView.text=@"";
//                    _textviewImage.hidden=YES;
//                    _textviewLabel.hidden=YES;
                    _priceDetailtotalValueLabel.text=@"";
                    priceDetailDiscountValueFloat=0;
                    
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                        
                        if (_timer!=nil) {
                            [_timer invalidate];
                            _timer=nil;
                        }
                    [Global loginViewController:self noteStr:requestResultStr];
                    //    [Global loginViewController:self];
                    }
                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
        
    }

}
-(void)priceDetailAlphaView1Click
{
   // [_remarkTextView1 resignFirstResponder];
    [_discountTextField1 resignFirstResponder];
    [_discountRateTextField resignFirstResponder];
    [UIView animateWithDuration:0.5 animations:^{
        
        CGRect frame=_priceDetailViewContainer1.frame;
        
        frame.origin.y=768;
        [_priceDetailViewContainer1 setFrame:frame];
        
    } completion:^(BOOL finished){
        
    }];
     _discountTextField1.text=@"";
    _discountLabel1.text=@"";
    _discountRateTextField.text=@"";
//    _remarkTextView1.text=@"";
//    _textviewImage1.hidden=NO;
//    _textviewLabel1.hidden=NO;
}
-(void)priceDetailAlphaViewClick
{
    //[_remarkTextView resignFirstResponder];
    [_todayGoldPriceTextField resignFirstResponder];
    [_goldPriceTextField resignFirstResponder];
    [_processPriceTextField resignFirstResponder];
    [_processFeeTextField resignFirstResponder];
    [_cutGoldTextField resignFirstResponder];
    [_discountTextField resignFirstResponder];
    [UIView animateWithDuration:0.5 animations:^{
        
        CGRect frame=_priceDetailViewContainer.frame;
        
        frame.origin.y=768;
        [_priceDetailViewContainer setFrame:frame];
        
    } completion:^(BOOL finished){
        
    }];
    _weightLabel1.text=@"";
    _weightLabel2.text= @"";
    
    _todayGoldPriceTextField.text=@"";
    
    
    _processPriceTextField.text=@"";
    
   
    _cutGoldTextField.text=@"";
    _discountTextField.text=@"";
    _goldPriceTextField.text=@"";
    _processFeeTextField.text=@"";
    _cutGoldLabel.text=@"";
    _discountLabel.text=@"";
//    _remarkTextView.text=@"";
//    _textviewImage.hidden=NO;
//    _textviewLabel.hidden=NO;

    

}
-(void)updateColor:(UITextField *)sender
{
   // NSLog(@"2222");
    [sender setTextColor:[UIColor colorWithRed:153.0f/255.0f green:153.0f/255.0f blue:153.0f/255.0f alpha:1.0f]];
}
- (void) updateCountLabel:(UITextField *)sender
{
   
    if (sender.tag==100) {
         _goldPriceTextField.text=[NSString stringWithFormat:@"%0.02f",[weightStr floatValue]*[sender.text floatValue]];
    }
    else if (sender.tag==101)
    {
        _todayGoldPriceTextField.text=[NSString stringWithFormat:@"%0.02f",[sender.text floatValue]/[weightStr floatValue]];
        
        if ([_todayGoldPriceTextField.text floatValue]==0) {
             _todayGoldPriceTextField.text=@"";
        }
    }
    else if (sender.tag==102)
    {
        _processFeeTextField.text=[NSString stringWithFormat:@"%0.02f",[weightStr floatValue]*[sender.text floatValue]];
   }
    else if (sender.tag==103)
    {
        _processPriceTextField.text=[NSString stringWithFormat:@"%0.02f",[sender.text floatValue]/[weightStr floatValue]];
    }
   // else if (sender.tag==104)
   // {
    
   // }
    else if (sender.tag==105)
    {
        if ([sender.text floatValue] <=[_goldPriceTextField.text floatValue]+[_processFeeTextField.text floatValue]) {
             _discountLabel.text=[NSString stringWithFormat:@"-¥%0.02f",[sender.text floatValue]];
        }
        else
        {
            [_discountTextField resignFirstResponder];
            [UIView animateWithDuration:0.5 animations:^{
                
                CGRect frame=_priceDetailViewContainer.frame;
                
                frame.origin.y=0;
                [_priceDetailViewContainer setFrame:frame];
                
            } completion:^(BOOL finished){
                
            }];
            [Global showTextHudSub:@"请输入有效的折扣金额" view:self.view];
          
            _discountTextField.text=@"";
            _discountLabel.text=[NSString stringWithFormat:@"-¥%d",0];

        }
       
    }
   todayGoldPriceStr =_todayGoldPriceTextField.text;
   processPriceStr =_processPriceTextField.text;
    if([_cutGoldTextField.text floatValue]<[weightStr floatValue])
    {
   cutGoldStr= _cutGoldTextField.text;
 //   NSLog(@"cutGoldStr===%@",cutGoldStr);
     _cutGoldLabel.text= [NSString stringWithFormat:@"-¥%0.02f",[_cutGoldTextField.text floatValue]*([todayGoldPriceStr floatValue]+[_processPriceTextField.text floatValue])];
    }
    else
    {
        [_cutGoldTextField resignFirstResponder];
        [UIView animateWithDuration:0.5 animations:^{
            
            CGRect frame=_priceDetailViewContainer.frame;
            
            frame.origin.y=0;
            [_priceDetailViewContainer setFrame:frame];
            
        } completion:^(BOOL finished){
            
        }];
        [Global showTextHudSub:@"请输入有效的剪金克数" view:self.view];
        _cutGoldTextField.text=@"";

    }
    //_priceDetailtotalValueLabel.text=[NSString stringWithFormat:@"%0.02f",[_goldPriceTextField.text floatValue]+[_processFeeTextField.text floatValue]-[cutGoldStr floatValue]*([todayGoldPriceStr floatValue]+[_processPriceTextField.text floatValue])-[_discountTextField.text floatValue] ];
    
  //  _priceDetailtotalValueLabel.text=[Global floatConvertPercentile:[_goldPriceTextField.text floatValue]+[_processFeeTextField.text floatValue]-[cutGoldStr floatValue]*([todayGoldPriceStr floatValue]+[_processPriceTextField.text floatValue])-[_discountTextField.text floatValue]];
    priceDetailDiscountValueFloat=[_goldPriceTextField.text floatValue]+[_processFeeTextField.text floatValue]-[cutGoldStr floatValue]*([todayGoldPriceStr floatValue]+[_processPriceTextField.text floatValue])-[_discountTextField.text floatValue];
    _priceDetailtotalValueLabel.text=[Global floatConvertPercentile:priceDetailDiscountValueFloat];
    
}
- (void)textViewDidChange:(UITextView *)textView
{
     if (textView==_cashierTextView) {
       
       if (textView.text.length == 0) {
           _cashierTextViewImage.hidden=NO;
           _cashierTextViewLabel.hidden=NO;
           
       }
       else
       {
           _cashierTextViewImage.hidden=YES;
           _cashierTextViewLabel.hidden=YES;
           
       }
   }

}
-(void)textViewBeginInput
{
    
    if ((_cashierLastView.frame.origin.y+_cashierLastView.frame.size.height+_cashierSrollView.contentOffset.y+352>768)) {
        
        
        [UIView animateWithDuration:0.3 animations:^{
            CGFloat offset=0.0;
            CGRect frameA=_cashierLastView.frame;
            frameA.origin.y=768-([Global getKeyboardHeight]+_cashierTextView.frame.size.height+_cashierTextView.frame.origin.y);
            offset=frameA.origin.y-_cashierLastView.frame.origin.y+_cashierSrollView.contentOffset.y;
            
            CGRect viewFrame=_cashierSrollView.frame;
            viewFrame.origin.y=offset;
            _cashierSrollView.frame=viewFrame;
        } completion:^(BOOL finished){
            
        }];
    }

}
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
    
       if (textView==_cashierTextView) {
           [self performSelector:@selector(textViewBeginInput) withObject:nil afterDelay:0.1];
      
    }
    return YES;
}
- (void)textViewDidEndEditing:(UITextView *)textView
{
    if (textView==_cashierTextView) {
       
        [UIView animateWithDuration:0.2 animations:^{
            CGRect viewFrame=_cashierSrollView.frame;
            viewFrame.origin.y=0;
            _cashierSrollView.frame=viewFrame;
        } completion:^(BOOL finished){
             [_cashierSrollView setContentOffset:CGPointMake(0, 0)];
        }];

    }
//else if (textView==_remarkTextView)
//{
//    [UIView animateWithDuration:0.3 animations:^{
//        CGRect viewFrame=_priceDetailViewContainer.frame;
//        viewFrame.origin.y=0;
//        _priceDetailViewContainer.frame=viewFrame;
//    } completion:^(BOOL finished){
//        
//    }];
//}
    
    
}
- (void)textClick
{
    [_searchMemberTextField becomeFirstResponder];
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
   
  if (textField==_cashierSearchMemberTextField) {
        [self performSelector:@selector(textClick) withObject:nil afterDelay:0.1];
        [memberCodeArray removeAllObjects];
        [memberNameArray removeAllObjects];
        [memberPhoneArray removeAllObjects];
        [memberGradeArray removeAllObjects];
        [memberAddressArray removeAllObjects];
        [memberIntegralArray removeAllObjects];
        [memberIntegralAmountArray removeAllObjects];
        [memberSexArray removeAllObjects];
        [_searchMemberTableView reloadData];
        _totalMemberLabel.text=[NSString stringWithFormat:@"共有0个结果"];
        [UIView animateWithDuration:0.3 animations:^{
            CGRect viewFrame=_searchMemberViewContainer.frame;
            viewFrame.origin.y=0;
            _searchMemberViewContainer.frame=viewFrame;
        } completion:^(BOOL finished){
            
        }];
        return NO;
        
    }
else if (textField==_todayGoldPriceTextField||textField==_goldPriceTextField|| textField== _processFeeTextField||textField==_processPriceTextField
         )
{
    [UIView animateWithDuration:0.3 animations:^{
        CGRect viewFrame=_priceDetailViewContainer.frame;
        viewFrame.origin.y=0;
        _priceDetailViewContainer.frame=viewFrame;
    } completion:^(BOOL finished){
        
    }];

}
  else if ([textField isEqual:_cutGoldTextField]) {
      inputTextField=_cutGoldTextField;
      [self performSelector:@selector(cutGoldTextFieldBeginInput) withObject:nil afterDelay:0.1];
      
        }
    else if ([textField isEqual:_discountTextField])
    {
         inputTextField=_discountTextField;
        [self performSelector:@selector(discountTextFieldBeginInput) withObject:nil afterDelay:0.1];
       
    }
    else if (textField==_integralTextField)
    {
        inputTextField=_integralTextField;
       [self performSelector:@selector(integralTextFieldBeginInput) withObject:nil afterDelay:0.1];
      
    }
    else if (textField==_deductibleTextField)
    {
        
        inputTextField=_deductibleTextField;
        [self performSelector:@selector(deductibleTextFieldBeginInput) withObject:nil afterDelay:0.1];
      
    }
    else if (textField==_oldMeterialTextField)
    {
        [UIView animateWithDuration:0.3 animations:^{
            CGRect viewFrame=_cashierViewContainer.frame;
            viewFrame.origin.y=-110;
            _cashierViewContainer.frame=viewFrame;
        } completion:^(BOOL finished){
            
        }];
        
    }

//
    return YES;
}
-(void)cutGoldTextFieldBeginInput
{
    [UIView animateWithDuration:0.2 animations:^{
        
        CGFloat offset=0.0;
        CGRect frameA=_cutGoldTextField.frame;
        frameA.origin.y=768-([Global getKeyboardHeight]+_cutGoldTextField.frame.size.height);
        offset=frameA.origin.y-_cutGoldTextField.frame.origin.y;
        
        CGRect viewFrame=_priceDetailViewContainer.frame;
        viewFrame.origin.y=offset;
        _priceDetailViewContainer.frame=viewFrame;
       

    } completion:^(BOOL finished){
        
    }];
   

}
-(void)discountTextFieldBeginInput
{
    [UIView animateWithDuration:0.2 animations:^{
    CGFloat offset=0.0;
    CGRect frameA=_discountTextField.frame;
    frameA.origin.y=768-([Global getKeyboardHeight]+_discountTextField.frame.size.height);
    offset=frameA.origin.y-_discountTextField.frame.origin.y;
    
    CGRect viewFrame=_priceDetailViewContainer.frame;
    viewFrame.origin.y=offset;
    _priceDetailViewContainer.frame=viewFrame;
    } completion:^(BOOL finished){
        
    }];

}
-(void)integralTextFieldBeginInput
{
    if ((_decutibleView.frame.origin.y+_decutibleView.frame.size.height+_cashierSrollView.contentOffset.y-96+[Global getKeyboardHeight]>768)) {
        [UIView animateWithDuration:0.3 animations:^{
            CGFloat offset=0.0;
            CGRect frameA=_decutibleView.frame;
            frameA.origin.y=768-([Global getKeyboardHeight]+_integralButton.frame.size.height+_integralButton.frame.origin.y);
            offset=frameA.origin.y-_decutibleView.frame.origin.y+_cashierSrollView.contentOffset.y;
            
            CGRect viewFrame=_cashierSrollView.frame;
            viewFrame.origin.y=offset;
            _cashierSrollView.frame=viewFrame;
            
        } completion:^(BOOL finished){
            
        }];
    }

}
-(void)deductibleTextFieldBeginInput
{
    if ((_decutibleView.frame.origin.y+_decutibleView.frame.size.height+_cashierSrollView.contentOffset.y-141+[Global getKeyboardHeight]>768)) {
        [UIView animateWithDuration:0.3 animations:^{
            CGFloat offset=0.0;
            CGRect frameA=_decutibleView.frame;
            frameA.origin.y=768-([Global getKeyboardHeight]+_deductibleButton.frame.size.height+_deductibleButton.frame.origin.y);
            offset=frameA.origin.y-_decutibleView.frame.origin.y+_cashierSrollView.contentOffset.y;
            
            CGRect viewFrame=_cashierSrollView.frame;
            viewFrame.origin.y=offset;
            _cashierSrollView.frame=viewFrame;
        } completion:^(BOOL finished){
            
        }];
    }

}
-(void)keyBordDoneClick
{
 if (inputTextField==_integralTextField||inputTextField==_deductibleTextField) {
     [_cashierSrollView setContentOffset:CGPointMake(0, 0)];
     CGRect viewFrame0=_cashierSrollView.frame;
     viewFrame0.origin.y=0;
     _cashierSrollView.frame=viewFrame0;
     [UIView animateWithDuration:0.3 animations:^{
         CGRect viewFrame0=_cashierSrollView.frame;
         viewFrame0.origin.y=0;
         _cashierSrollView.frame=viewFrame0;

            CGRect viewFrame=_cashierViewContainer.frame;
            viewFrame.origin.y=0;
            _cashierViewContainer.frame=viewFrame;
        } completion:^(BOOL finished){
            
        }];
   }
    else if (inputTextField==_cutGoldTextField||inputTextField==_discountTextField)
    {
       // NSLog(@"1111111111");
        [UIView animateWithDuration:0.3 animations:^{
            CGRect viewFrame=_priceDetailViewContainer.frame;
            viewFrame.origin.y=0;
            _priceDetailViewContainer.frame=viewFrame;
        } completion:^(BOOL finished){
            
        }];

    }
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
     [textField resignFirstResponder];
    if (textField==_integralTextField||textField==_deductibleTextField||textField==_oldMeterialTextField) {
    if (textField==_integralTextField)
    {
        if ([_integralTextField.text floatValue]>[integralAvailabalStr floatValue]) {
            if ([integralAvailabalStr floatValue]==0) {
                [Global showTextHudSub:@"您的可用金额为0" view:self.view];
               
            }
            else
            {
               [Global showTextHudSub:@"您输入的金额已大于可用金额，请重新填写" view:self.view];
            
            }
            _integralTextField.text=@"";
            balanceAmountFloat=cashierAmountFloat-[_deductibleTextField.text floatValue]-[_oldMeterialTextField.text floatValue];
            NSString *AvgPriceStr=[Global floatConvertPercentile:balanceAmountFloat];
            _balancePayLabel.text=AvgPriceStr;
           
            
//            float decutibleFloat=[_integralTextField.text floatValue]+[_depositText.text floatValue]+[_deductibleTextField.text floatValue]+[_oldMeterialTextField.text floatValue];
//            _decutibleLabel.text=[Global floatConvertPercentile:decutibleFloat];
//            _cashierLastTotalLabel.text=[Global floatConvertPercentile:cashierAmountFloat-decutibleFloat];
            
        }
//        else
//        {
            float decutibleFloat=[_integralTextField.text floatValue]+[_depositText.text floatValue]+[_deductibleTextField.text floatValue]+[_oldMeterialTextField.text floatValue];
            _decutibleLabel.text=[Global floatConvertPercentile:decutibleFloat];
            _cashierLastTotalLabel.text=[Global floatConvertPercentile:cashierAmountFloat-decutibleFloat];
//        }
       

    }
    if (textField==_deductibleTextField) {
//        if([_deductibleTextField.text floatValue]>(cashierAmountFloat-[_oldMeterialTextField.text floatValue]-[_integralTextField.text floatValue]))
//        {
//            UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"您输入的金额已大于支付金额，请重新填写" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
//            [alert show];
//            _deductibleTextField.text=@"";
//           // _balancePayLabel.text=[NSString stringWithFormat:@"%0.02f",cashierAmountFloat-[_oldMeterialTextField.text floatValue]-[_integralTextField.text floatValue]];
//            balanceAmountFloat=cashierAmountFloat-[_oldMeterialTextField.text floatValue]-[_integralTextField.text floatValue];
//            NSString *AvgPriceStr=[Global floatConvertPercentile:balanceAmountFloat];
//            _balancePayLabel.text=AvgPriceStr;
////
//            
//        }
//        else
//        {
            float decutibleFloat=[_integralTextField.text floatValue]+[_depositText.text floatValue]+[_deductibleTextField.text floatValue]+[_oldMeterialTextField.text floatValue];
            _decutibleLabel.text=[Global floatConvertPercentile:decutibleFloat];
        _cashierLastTotalLabel.text=[Global floatConvertPercentile:cashierAmountFloat-decutibleFloat];
        }

    }
   
    else if(textField==_todayGoldPriceTextField||textField==_goldPriceTextField||textField==_processFeeTextField||textField==_processPriceTextField||textField==_cutGoldTextField||textField==_discountTextField)
    {
        [_processPriceTextField setTextColor:[UIColor blackColor]];
        [_cutGoldTextField setTextColor:[UIColor blackColor]];
        [_discountTextField setTextColor:[UIColor blackColor]];
        [_processFeeTextField setTextColor:[UIColor blackColor]];
        [_todayGoldPriceTextField setTextColor:[UIColor blackColor]];
        [_goldPriceTextField setTextColor:[UIColor blackColor]];
    }
 
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
   
    if (textField==_searchMemberTextField) {
        [_searchMemberTextField resignFirstResponder];
        [memberCodeArray removeAllObjects];
        [memberNameArray removeAllObjects];
        [memberPhoneArray removeAllObjects];
        [memberGradeArray removeAllObjects];
        [memberAddressArray removeAllObjects];
        [memberIntegralArray removeAllObjects];
        [memberIntegralAmountArray removeAllObjects];
        [memberSexArray removeAllObjects];
        
        _memberPageIndex=0;
        [self loadMemberNextPage:_memberPageIndex];
        
        
        // return NO;
    }

   else if (textField==_integralTextField||textField==_deductibleTextField||textField==_oldMeterialTextField) {
        // NSLog(@"ddddd1111");
        [_integralTextField resignFirstResponder];
        [_deductibleTextField resignFirstResponder];
        [_oldMeterialTextField resignFirstResponder];
       

        [UIView animateWithDuration:0.3 animations:^{
            CGRect viewFrame=_cashierViewContainer.frame;
            viewFrame.origin.y=0;
            _cashierViewContainer.frame=viewFrame;
        } completion:^(BOOL finished){
            
        }];
    }
   else if (textField==_weightTextField||textField==_recoveryGoldPriceTextField||textField==_lossTextField)
   {
       [_weightTextField resignFirstResponder];
       [_recoveryGoldPriceTextField resignFirstResponder];
       [_lossTextField resignFirstResponder];
   }
else if(textField==_processPriceTextField||textField==_cutGoldTextField||textField==_discountTextField||textField==_processFeeTextField||textField==_todayGoldPriceTextField||textField==_goldPriceTextField)
{
   // NSLog(@"4444444");
    [_processPriceTextField setTextColor:[UIColor blackColor]];
    [_cutGoldTextField setTextColor:[UIColor blackColor]];
    [_discountTextField setTextColor:[UIColor blackColor]];
    [_processFeeTextField setTextColor:[UIColor blackColor]];
    [_todayGoldPriceTextField setTextColor:[UIColor blackColor]];
    [_goldPriceTextField setTextColor:[UIColor blackColor]];
    
    [_todayGoldPriceTextField resignFirstResponder];
    [_goldPriceTextField resignFirstResponder];
    [_processPriceTextField resignFirstResponder];
    [_cutGoldTextField resignFirstResponder];
    [_discountTextField resignFirstResponder];
    [_processFeeTextField resignFirstResponder];
    [UIView animateWithDuration:0.3 animations:^{
        CGRect viewFrame=_priceDetailViewContainer.frame;
        viewFrame.origin.y=0;
        _priceDetailViewContainer.frame=viewFrame;
    } completion:^(BOOL finished){
        
    }];
}
    else if (textField==_discountTextField1)
    {
        [_discountTextField1 resignFirstResponder];
    }
      return YES;
}
-(void)requestChengSe
    {
        
        if ([Global getLoginToken].length>0) {
            [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
            NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
            [params setObject:[Global getLoginToken] forKey:@"Token"];
            [params setObject:_cashierSearchMemberTextField.text forKey:@"UserCode"];
            
            [HttpRequest requestData:@"Guide/FinenessList" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
                // NSLog(@"serrr111==%@",severDataDict.dataDict);
                // [_cashierSearchMemberTextField resignFirstResponder];
                if (isSuccess) {
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                        [Global hideProgressHUDInternal:self.view];
                        [chengSeNameArray removeAllObjects];
                        [chengSeCodeArray removeAllObjects];
                        if ([severDataDict.dataDict objectForKey:@"ResultString"]!= [NSNull null] )
                        {
//                            NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
//                            //  [Global showTextHud:requestResultStr view:self.view];
//                            [Global showTextHudSub:requestResultStr view:self.view];
                            
                            NSMutableArray *dataLineArray=[NSMutableArray arrayWithArray:[severDataDict.dataDict objectForKey:@"DataLine"]];
                            for (int i=0; i<dataLineArray.count; i++) {
                                [chengSeCodeArray addObject:[[dataLineArray objectAtIndex:i] objectForKey:@"FinenessCode"]];
                                [chengSeNameArray addObject:[[dataLineArray objectAtIndex:i] objectForKey:@"FinenessName"]];
                            }
                            [_chengSeTableView reloadData];
                        }
                        
                        
                    }
                    else
                    {
                        [Global hideProgressHUDInternal:self.view];
                        NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                        //  [Global showTextHud:requestResultStr view:self.view];
                        [Global showTextHudSub:requestResultStr view:self.view];
                        
                        if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                            
                            if (_timer!=nil) {
                                [_timer invalidate];
                                _timer=nil;
                            }
                        [Global loginViewController:self noteStr:requestResultStr];
                        //    [Global loginViewController:self];
                        }
                    }
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    [Global showTextHudSub:@"连接失败" view:self.view];
                }
            }];
        }
    }

-(void)addMemberBtnClick
{
    if (_timer!=nil) {
        [_timer invalidate];
        _timer=nil;
    }
    if (addMemberVC.view!=nil) {
        
        [addMemberVC removeFromParentViewController];
        [addMemberVC.view removeFromSuperview];
        
    }
    addMemberVC=[[AddMemberViewController alloc] init];
    addMemberVC.delegate=self;
    addMemberVC.addOrEditStr=@"A";
    addMemberVC.userCodeStr=@"";
    addMemberVC.docNumStr=@"";
    addMemberVC.view.frame = CGRectMake(0,
                                        0,
                                        self.view.bounds.size.width,
                                        self.view.bounds.size.height);
    
    [self addChildViewController:addMemberVC];
    [self.view addSubview:addMemberVC.view];
    
    
    
}
-(void)addOrEditMemberSuccess:(NSString *)memberCodeString memberGradeString:(NSString *)memberGradeString memberNameString:(NSString *)memberNameString memberPhoneString:(NSString *)memberPhoneString memberSexString:(NSString *)memberSexString memberIntegralString:(NSString *)memberIntegralString
{
    
        NSString * integralStr =memberIntegralString;
        _memberIntegralLabel.text=integralStr;
        _memberIntegralLabel.hidden=NO;
        _memberIntegralTagLabel.hidden=NO;
   
    
    _memberAndPhoneLabel.text=[NSString stringWithFormat:@"%@(%@)",memberNameString,memberPhoneString];
    memberCodeStr=memberCodeString;
    if (_memberAndPhoneLabel.text.length>0) {
        
        //     [self resizeLabel:_memberAndPhoneLabel];
        [Global resizeForLable:_memberAndPhoneLabel WithText:_memberAndPhoneLabel.text parentView:self.view];
        
        integralAvailabalStr=@"";
        _integralAvailabelLabel.text=[NSString stringWithFormat:@"可抵  ¥ 0.00"];
        
        NSString *gradeStr=memberGradeString;
        _memberGradeLabel.text=gradeStr;
        _memberGradeTagLabel.hidden=NO;
        _memberGradeLabel.hidden=NO;
            //  [self resizeLabel:_memberGradeLabel];
        [Global resizeForLable:_memberGradeLabel WithText:_memberGradeLabel.text parentView:self.view];
            //_memberGradeLabel.text=[severDataDict.dataDict objectForKey:@"Grade"];
        
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
